| rvbplayer123 (12) | |||
I'm writing a program that reads text from a text file into a c-string and then convert the ascii character to integer. I already did the reverse process. integer>ascii. How do I do ascii>integer
| |||
|
|
|||
| Athar (4382) | ||
You don't say... why would you expect anything else after doing this? c = 'a'; | ||
|
|
||
| Moschops (5961) | ||||
OP:
| ||||
|
|
||||
| vlad from moscow (3112) | |
|
You need no a special function to convert an object of type char to int because char is already an integral type. All what you need is to assign a char object to an int object or use casting. For example char c = 'a'; std::cout << a << std::endl; // output is a std::cout << ( int )a << std::endl; // output is 97 int i = c; std::cout << a << std::endl; // output is a std::cout << i << std::endl; // output is 97 | |
|
|
|
| Jackson Marie (462) | |
|
"Char to int" is always correct. Why did you ask this question? Spam? Or just ask everyone how to print character code (int)? | |
|
|
|