|
-
Mar 15th, 2001, 08:08 PM
#1
Thread Starter
Junior Member
What are the c++ conversion functions for ASC() and CHR()
-
Mar 15th, 2001, 11:24 PM
#2
Addicted Member
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;
}
-
Mar 16th, 2001, 01:03 AM
#3
Frenzied Member
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
Harry.
"From one thing, know ten thousand things."
-
Mar 17th, 2001, 07:18 PM
#4
Thread Starter
Junior Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|