Click to See Complete Forum and Search --> : ASC CHR conversion
random150
Mar 15th, 2001, 07:08 PM
What are the c++ conversion functions for ASC() and CHR()
KingDavid
Mar 15th, 2001, 10:24 PM
This is all I know on the subject
#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;
}
HarryW
Mar 16th, 2001, 12:03 AM
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
random150
Mar 17th, 2001, 06:18 PM
thanx for the help
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.