求解:for(;*p;)什么意思?
c语言吧
全部回复
仅看楼主
level 1
rt
for循环缺少了条件事什么意思
2012年05月06日 15点05分 1
level 1
DD
2012年05月06日 15点05分 2
level 1
DD
2012年05月06日 15点05分 3
level 12
1.3空语句,不执行。
只判断*p
2012年05月06日 15点05分 4
level 11
for(;*p;)等同于for(;*p !='\0';)或者直接写while(*p)更简洁
2012年05月06日 15点05分 5
level 1
好的 谢谢!!
2012年05月06日 15点05分 6
level 1
谢谢
2012年05月06日 15点05分 7
level 11
一般非bool类型(或者判断条件只是真或假)不建议写成那样,不过好多人还是那样写....
我还是习惯写作 while ( *p != '\0' )
2012年05月06日 15点05分 8
level 1
恩 了解了
2012年05月06日 15点05分 9
level 7
但是它的执行效率会降低
2012年05月06日 15点05分 10
level 11
不会的,编译器优化的结果一样。但是明显后者可读性好。
2012年05月07日 04点05分 11
level 7
你写程序是凭借编译器优化代码的吗?
2012年05月07日 04点05分 12
level 13

2012年05月07日 04点05分 13
level 13
while(*p)其实接近约定俗成了...
2012年05月07日 04点05分 14
level 11
肯定啊..
2012年05月07日 04点05分 15
level 11
没错....最早开始学的时候被别人告知如果不是bool类型别那么写,现在习惯了之后难改了...
2012年05月07日 04点05分 16
level 13
话说只要写makefile
绝对加上(不一定是同样的但是相似) -std=gnu++0x -O2-O3
2012年05月07日 04点05分 17
level 7
我好像闭门造车了,受教
2012年05月07日 05点05分 18
1