0

Here is my code:

void f(char c) {
std::cout << c << '\t'
    << (int)c << '\t'
    << std::hex << (int)c << std::endl;
}

int main() {
  f('a');
  f('b');
  f('c');
}

What I want is like: char intOfChar hexIntOfChar. But result is:

a   97  61
b   62  62
c   63  63

What I expect is:

a   97  61
b   98  62
c   99  63

I try to figure it out but fail. So how do ostream cout and hex work?

liaoming
  • 153
  • 3
  • 10

0 Answers0