考虑以下代码:
extern "C" {
#include <lib.h>
}
#include <iostream>
int main() {
unsigned char a='a';
unsigned char b=some_struct_in_libh->unsignedchar;
cout << a << " " << b << endl; //Prints only a
printf("%u\n",b); //Prints b
cout << static_cast<int>(b) << endl; //Also prints b
return 0;
}
为什么它会这样?