Computer Science Canada

ASCII

Author:  The_$hit [ Wed May 11, 2005 7:31 pm ]
Post subject:  ASCII

how do you change a lettre into its ASCII value in C++?

Author:  1of42 [ Wed May 11, 2005 8:51 pm ]
Post subject: 

I believe you can just cast it into an int, and vice versa.

Author:  wtd [ Wed May 11, 2005 8:53 pm ]
Post subject: 

code:
char ch('t');
int i(static_cast<int>(ch));

Author:  The_$hit [ Thu May 19, 2005 6:49 pm ]
Post subject: 

ok ty

i found you can do:

code:

char a="a";
int blah=int(a);

Author:  wtd [ Thu May 19, 2005 7:07 pm ]
Post subject: 

The_$hit wrote:
ok ty

i found you can do:

code:

char a="a";
int blah=int(a);


Character constants must be surrounded by single-quotes, not double-quotes.

Take advantage of implicit conversion and the C++ initialization syntax.

c++:
char a('a');
int blah(a);


: