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.

Recommended Answers

Is that what you asking?

char alpha='A';
int x=alpha;
Jump to Post

All 3 Replies

Is that what you asking?

char alpha='A';
int x=alpha;

Will it work with user imput instead of asineing a constant to it?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.