《C程序設(shè)計(jì)語(yǔ)言》第二版的習(xí)題5.1:用指針的方式實(shí)現(xiàn)strcat即字符串連接函數(shù)。這個(gè)是可以實(shí)現(xiàn)的#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++) ;}輸出結(jié)果為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++) ;}輸出結(jié)果:Hello
while(*s++); 和 while(*s)s++; 的區(qū)別?
瀟瀟雨雨
2019-04-06 08:31:56