How do I get the ASCII code for a char type variable?
And How do I convert ASCII code back to a character?
You can use a cast to convert it to int from char and the oppoosite.
Here is an example:
using namespace std;
cout << "Give character: ";
cin >> ascii;
cout << "Its ascii value is: " << (int) ascii << endl;
cout << "Give a number to convert to ascii: ";
cin >> numeric;
cout << "The ascii value of " << numeric << " is " << (char) numeric;
Last edited on
Thank you very much for the prompt reply... I will try this...
its just the dec value of ascii code... how 'bout the hex value???
Thanks simo110!!! thank you very much!!! mwah!!! XD