Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using 'LEFT', 'MID' and 'RIGHT' and how to convert a character to int

Status
Not open for further replies.

spippo

Programmer
Mar 13, 2003
3
BE
In borland C++ Builder 3 there are the commands 'LEFT' 'RIGHT' and 'MID'
They supose to work like this:

LEFT("Spippo",3) = "Spi"
RIGHT("Spippo",2) = "po"
MID("Spippo",2,3) = "pip"

When I use them, it sais:
[C++Error] Unit2.cpp(48): Call to undefined function 'MID'.

I've include <strings.h> is there something else I have to include?

How can I convert a charter to is ANSII-code?
eg:
&quot;a&quot; = 97
&quot;b&quot; = 98
...
 
I've never been able to get LEFT, RIGHT, or MID to work. I've always dropped back to substr which works like MID.
Code:
string WorkOn = &quot;Spippo&quot;;
WorkOn.substr(0,3); // &quot;Spi&quot;
WorkOn.substr(4,2); // &quot;po&quot; you could also use length - 2
WorkOnsubstr(1,3); // &quot;pip&quot;

For the last question, look at toascii.
Code:
int A = toascii('a');
int B = toascii('b');

I'm doing this from memory so double check your Docs. James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
This may also be helpful.

int x;

x = (int)'a';

Label1->Caption = x;

tomcruz.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top