0

次のコードを検討してください。

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;
}

なぜこのように振る舞うのですか?

4

1 に答える 1