int main() { int i = 2147483647; unsigned int ui = 2147483647; if (i + 1 < 0) printf("i + 1 < 0\n"); if (ui + 1 > 0) printf("ui + 1 > 0\n"); if (ui + 1 > i + 1) printf("ui + 1 > i + 1\n"); return 0; }The output.
C:\SVN\book\C>a.exe i + 1 < 0 ui + 1 > 0
最後一個是因為 ui+1 > (unsigned int) (i+1)
回覆刪除