0

i'm new to c++....i'm making a project here but i have a problem with this: reading values as type char and converting it to type int...such that 54 can be read as '5' and '4' but after that it will be read into type int...can anyone please tell me how?

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by Ancient Dragon
0

a char is nothing more than a small one-byte integer. To convert a char to an int use the assignment

char c = 'A';
int n = c;

Or if all you want to do is print the int value of the char, just typecast it

char c = 'A';
cout << (int)c;
This topic has been dead for over six months. 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.