《C程序設計語言》第二版的習題5.1:用指針的方式實現strcat即字符串連接函數。這個是可以實現的#includevoidstrcatp(char*s,char*t);intmain(){ chars[]="Hello"; chart[]="world!"; strcatp(s,t);printf(s); return0;}voidstrcatp(char*s,char*t){while(*s)s++;while(*s++=*t++) ;}輸出結果為Helloworld!而這種卻不行?#includevoidstrcatp(char*s,char*t);intmain(){ chars[]="Hello"; chart[]="world!"; strcatp(s,t);printf(s); return0;}voidstrcatp(char*s,char*t){while(*s++);while(*s++=*t++) ;}輸出結果:Hello
while(*s++); 和 while(*s)s++; 的區別?
瀟瀟雨雨
2019-04-06 08:31:56