[cfe-dev] uint8_t not getting output to cout?
Shriramana Sharma via cfe-dev
cfe-dev at lists.llvm.org
Tue Feb 12 20:11:53 PST 2019
Hello. Please see the following simple code:
#include <cstdint>
#include <cstdio>
#include <iostream>
int main()
{
std::uint16_t y = 2019;
std::uint8_t m = 2, d = 13;
std::printf("%d-%d-%d\n", y, m, d);
std::cout << y << '-' << m << '-' << d << std::endl;
std::cout << int(y) << '-' << int(m) << '-' << int(d) << std::endl;
}
The above code outputs:
2019-2-13
2019- -
2019-2-13
The character on the second line after the hyphen is Unicode codepoint 0x0002!
The same behaviour happens with both Clang 6 and GCC 7.3.0 available
by default on my Kubuntu Bionic LTS system.
What is wrong with expecting std::cout to properly print uint8_t when
printf can do it?
--
Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा 𑀰𑁆𑀭𑀻𑀭𑀫𑀡𑀰𑀭𑁆𑀫𑀸
More information about the cfe-dev
mailing list