C++ std::cout displaying 64

Viewed 131

std::cout << 100 << std::endl;

I've written this code but when I go to see the result it prints 64? Anyone has any ideia why this is?

1 Answers

Here you are.

#include <iostream>
#include <iomanip>

int main() 
{
    std::cout << 100 << std::endl;
    std::cout << std::hex << 100 << std::endl;
    std::cout << 100 << std::endl;
    std::cout << std::dec << 100 << std::endl;
    std::cout << 100 << std::endl;

    return 0;
}

The program output is

100
64
64
100
100

You got the output 64 because somewhere in the preceding code there was used the standard manipulator std::hex.

Related