简体   繁体   中英

C++ std::cout displaying 64

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM