Results 1 to 3 of 3

Thread: Finding ASCII code

  1. #1

    Thread Starter
    Fanatic Member x-ice's Avatar
    Join Date
    Mar 2004
    Location
    UK
    Posts
    671

    Resolved Finding ASCII code

    I have a char variable with the character 'a' in it. How can i find the ASCII value of this?

    p.s. I know its the ASCII value of 'a', but i need to use my program to find it.
    Last edited by x-ice; Oct 12th, 2006 at 07:18 PM.

  2. #2
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403

    Re: Finding ASCII code

    In C/C++, you can simply cast a char to an int in order to see it's character code.

    Code:
    char c = 'a';
    
    cout << "the code for " << c << " is: " << (int)c << endl;
    Hope this helps.
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  3. #3

    Thread Starter
    Fanatic Member x-ice's Avatar
    Join Date
    Mar 2004
    Location
    UK
    Posts
    671

    Resolved Re: Finding ASCII code

    Quote Originally Posted by sunburnt
    In C/C++, you can simply cast a char to an int in order to see it's character code.

    Code:
    char c = 'a';
    
    cout << "the code for " << c << " is: " << (int)c << endl;
    Hope this helps.
    That helps, thanks.

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