0

ok all I need is to learn how to convert a char variable into a acsii byte and back again.
€£¥$
Edit: I know about typecasting or something and it's not exactly what I need because I wat to store the new variable in a int vareuble and I don't know how to use it.

Edited by Zssffssz: Clarification

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by Fbody
0

It depends on how you do the user input. Simply doing this:

int userInput;
cin >> userInput;

will not work if the user enters any sort of char input (such as 'A'). It will corrupt the stream and mess up your program.

To prevent this you'll have to get the user's input in char format, then convert it to an int.

EDIT:
And just an FYI, it's ASCII, not ACSII

Edited by Fbody: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.