|
-
Feb 1st, 2002, 03:22 PM
#1
Thread Starter
Lively Member
ASCII codes from string (Borland C++ Builder)
I am searching for an equivalent of the VisualBasic function Asc() to get the ASCII code of a letter.
I'm using Borland C++ Builder 5 and AnsiString data types. This is my code:
Code:
AnsiString strText = txtInput->Text[2] //To get only the 2nd character of the Edit box
-
Feb 1st, 2002, 05:00 PM
#2
Use the "char" data type. It contains a single character, which is that characters ASCII value.
Z.
-
Feb 1st, 2002, 05:14 PM
#3
Thread Starter
Lively Member
I have heard of this, but how can I get the ASCII code from the char variable? Can you give me an example?
-
Feb 1st, 2002, 05:28 PM
#4
Thread Starter
Lively Member
I just got it by myself:
Code:
char chrBuffer;
int intBuffer;
for (int i = 1; i <= StrLen(strText.c_str()); i++)
{
chrBuffer = txtKlartext->Text[1];
intBuffer = chrBuffer;
txtASCII->Text = txtASCII->Text + IntToStr(intBuffer);
}
Thx for the hint!
-
Feb 2nd, 2002, 01:29 PM
#5
Fanatic Member
or you can do
PHP Code:
char cTst = 'a';
//get ascii value
printf("%d", int(cTst)); //print out 65
printf("%c", char(65)); //print out 'a'
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|