f(char *s) {char *p=s; while(*p!='\0'); p++; return (p-s); } main() {printf("%d\n",f("ABCDEF")); }

问题描述:

f(char *s) {char *p=s; while(*p!='\0'); p++; return (p-s); } main() {printf("%d\n",f("ABCDEF")); }

while(*p!='\0') p++;
把while后面的分号去掉,不然p只加一次,返回总是1.