Prints the integer equivalent of a character typed at the keyboard. Store the input in a variable type of char. - C++ Data Type

C++ examples for Data Type:char

Description

Prints the integer equivalent of a character typed at the keyboard. Store the input in a variable type of char.

Demo Code

#include <iostream>

int main(int argc, const char *argv[]) {
    char char1;

    std::cout << "Enter a character: ";
    std::cin >> char1;

    std::cout << "Integer equivalent of " << char1 << ": ";
    std::cout << static_cast<int>(char1) << std::endl;

    return 0;/*w  w  w .  j  a  va  2  s.co m*/
}

Result


Related Tutorials