考虑以下 C++ 代码:
输出结果为:
#include <cstdio>
using namespace std;
int main()
{
int ia = -5;
unsigned int uia = ia;
char ca = -5;
unsigned char uca = ca;
printf("%d\n", (ia == uia));
printf("%d\n", (ca == uca));
return 0;
}
输出结果为:
1
0
当从 signed
转换为 unsigned
时,我不理解 int
和 char
之间的区别是什么?
你能否给我讲解一下呢?