0
How do I return the ASCII value of a char variable?
I understand that char stores a single character as an ASCII value. Is there an easy way in C++ to return the ASCII value of a char variable instead of the letter itself, as in: main() char someLetter; cout << "Enter a letter--> "; cin someLetter; cout << "The ASCII value of the letter you typed is " << ???; return(0);
4 odpowiedzi
+ 2
char c;
cin>>c;
cout<<static_cast<int>(c);
+ 2
Don't works for Unicode i think but they arent ascii
0
Excellant! Exactly what I was looking for, thank you.
0
Can char hold non-ascii unicode characters?