如果s是一个char型指针,也即char *s; 则可以写成 *s='\0'int i=0 while(s[i]!='\0')i++;是对的,如果while中还有其他语句,需要加{ }也即int i=0 while(s[i]!='\0'){ i++;}