一小段代码让我发疯,但希望你能阻止我跳出窗外。看这里:
#include <iostream>
#include <cstdint>
int main()
{
int8_t i = 65;
int8_t j;
std::cout << "i = " << i << std::endl; // the 'A' is ok, same as uchar
std::cout << "Now type in a value for j (use 65 again): " << std::endl;
std::cin >> j;
std::cout << "j = " << j << std::endl;
if (i != j)
std::cout << "What is going on here?????" << std::endl;
else
std::cout << "Everything ok." << std::endl;
return 0;
}
如果我使用int
而不是int8_t
一切正常。我需要这个 8-bit unsigned integers
,而不是更大。顺便说一句。与unsigned char
它的行为相同 - 当然 - 与int8_t
.
有人有提示吗?