Home c++ How to get the code of a character that is in Char

How to get the code of a character that is in Char

Author

Date

Category

Using studio always just subtracted ‘0’ from this variable


Answer 1, authority 100%

A char does not contain a character, but just its code, which is interpreted by the I / O system as a character. If you need to display these values ​​in the terminal, you can do this

char a = 'a';
std::cout << (int) a << std::endl;

Or more culturally:

std :: cout & lt; & lt; static_cast & lt; int & gt; (a) & lt; & lt; std :: endl;

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions