我沒有一個方便的編譯器來自己檢查。C99單行比較語法快捷鍵
- 版本1(以下)中的代碼是否在C C99中有效?它會編譯並運行正常嗎?
- 它在邏輯上等同於版本2中的代碼嗎?
版本1:
int a, b, c, d;
... some code to set the above variables ...
if (a != b != c != d)
//Do something
... rest of code ...
版本2:
int a, b, c, d;
... some code to set the above variables ...
if ((a != b) && (a != c) && (a != d) && (b != c) && (b != d) && (c != d))
//Do something
... rest of code ...
如果您在線有幾個[在線編譯器](http://stackoverflow.com/questions/3916000/online-c-compiler-and-evaluator)可用,並至少與Coliru和ideone,它是直接前往使用C99。 –