我正在编写c程序,它将在世界上大多数C编译器中编译(windows,linux,solaris,mac,aix,hpux,vxworks(arm,ppc,mips...),windriver linux的编译器等)
如果我按照C标准写程序可以吗operator precedence
最佳答案
是的,会好的。
但是,当有疑问时,请使用括号!
int a = 2 * 3 / 4; /* 0 or 1 ? */
int b = (2 * 3) / 4; /* definitely 1 */
int c = 2 * (3 / 4); /* definitely 0 */
有多余的括号比错误的结果要好得多。
关于c - 是否所有的C编译器都严格遵循运算符优先顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12005369/