Results 1 to 5 of 5

Thread: ASCII codes from string (Borland C++ Builder)

  1. #1

    Thread Starter
    Lively Member floppes's Avatar
    Join Date
    May 2001
    Location
    Darmstadt, Germany
    Posts
    99

    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

  2. #2
    Zaei
    Guest
    Use the "char" data type. It contains a single character, which is that characters ASCII value.

    Z.

  3. #3

    Thread Starter
    Lively Member floppes's Avatar
    Join Date
    May 2001
    Location
    Darmstadt, Germany
    Posts
    99
    I have heard of this, but how can I get the ASCII code from the char variable? Can you give me an example?

  4. #4

    Thread Starter
    Lively Member floppes's Avatar
    Join Date
    May 2001
    Location
    Darmstadt, Germany
    Posts
    99

    Wink

    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!

  5. #5
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    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
  •  



Click Here to Expand Forum to Full Width