for(; p; p++)中的p!= 0为什么只在字符串末端的\0生效,而字符串中的0他不会跳出循环,完整代码如下
#include <stdio.h>
int main(void){
char buf[512];
char exist[128]={0};
int cnt;
while(gets(buf) != NULL){
char *p = buf;
cnt = 0;
for(; *p; p++){
if(!exist[*p]){
exist[*p] = 1;
++cnt;
}
}
printf("%d\n", cnt);
}
return 0;
}