What are the c++ conversion functions for ASC() and CHR()
Printable View
What are the c++ conversion functions for ASC() and CHR()
This is all I know on the subject
Code:#include <iostream.h>
#include <ctype.h>
void main()
{
int i;
char c;
// typecast
c = (char)97; // convert to character
cout << c << endl;
i = (int)'a'; // convert to integer
cout << i << endl;
i = (int)"a"; // NOTE: "a" is not the same as 'a'
cout << i << endl;
// no type cast
c = 97;
cout << c << endl;
i = 'a';
cout << i << endl;
// Function
i = __toascii('a');// convert to integer
cout << i << endl;
}
The character type is just an 8-bit integer. The character itself is stored as an ASCII code, so there is no need to convert it really, you just need to cast it from one type to the other so that the compiler knows how you want to deal with the information.
I haven't seen __toascii() before, but it's probably just a macro like this:
#define __toascii(a) (int)a
thanx for the help