但 int 是變長的,16機是16位(2字節),32位機就是32位(4字節),64位機就是64位(8字節)。現在很多學校還在用非常老的教材,說 int 是占2個字節。
我想樓主可能是認為 int 是2個字節 ,16位全為1的時候是 65535 ,而加了個 unsigned 變成了無符號整數了,就搞不清楚輸出什麽結果了。其實,實際運行妳會發現,無論加不加 unsigned ,輸出的都是 65535。如果換成
short b=65535;
將會輸出 -1
而 unsigned short b=65535; 則輸出 65535 。