/*
Check if there are same charactors in
the string.And it may be the most
effective way.
*/
#include <stdio.h>
main(int argc,char *argv[]){
puts(argv[1]);
char num[256]=; /*good way to init a char array*/
unsigned char *pos = (unsigned char *)argv[1];
while(*pos!=0&&num[*pos]==0){
/*
"*pos" used for checking if the string goes end.
"num[*pos]==0" used for checking if the char appeared before.
*/
num[*pos++]=1;
}
printf("%i\n",(*pos==0?0:1));
}
心得:
*用初始化数组。