网站怎么制作的,90后做网站月入万元,汕头百度推广公司,北京协会网站建设Strtok#xff1a;原型char *strtok(char s[], const char *delim); s为要分解的字符#xff0c;delim为分隔符字符#xff08;如果传入字符串#xff0c;则传入的字符串中每个字符均为分割符#xff09;。首次调用时#xff0c;s指向要分解的字符串#xff0c;之后再次… Strtok原型char *strtok(char s[], const char *delim); s为要分解的字符delim为分隔符字符如果传入字符串则传入的字符串中每个字符均为分割符。首次调用时s指向要分解的字符串之后再次调用要把s设成NULL。在头文件#includestring.h中。strtok函数会破坏被分解字符串的完整调用前和调用后的s已经不一样了。如果要保持原字符串的完整可以使用strchr和sscanf的组合等。 返回拆出来字符串首地址 第1个参数第一次传要拆的串第二次传NULL表示向下拆 第2个参数用哪些字符做分割符将分割符改成\0返回 #include string.h
void read_all_words1(char (*words)[1000],int *pCnt){char str[1000000] {0};char * p str;gets(str);while(p strtok(p, )){strcpy(words[(*pCnt)],p);(*pCnt);p NULL;}
}
void read_all_words(char (*word)[1000],int *pCnt) {do{scanf(%s,word[(*pCnt)]);(*pCnt);}while(getchar()!\n);
}
int main(){char words[1000][1000] {0};int cnt 0;//read_all_words(words,cnt);read_all_words1(words,cnt);for(int i 0;icnt;i){printf(%s ,words[i]);}
}#includestdio.h
#includestring.h
enum status{BLANK,CHAR};
int fun(char str[]){int words 0;char temp[100] { };strcat(temp,str);strcat(temp, );for(int i 1;i strlen(temp)-2;i){if(temp[i] ! temp[i-1] ){words ;}}return words;
}
int main(){char * p i am a boy;printf(%d,fun(p));
}#includestdio.h
#includestring.h
enum status{BLANK,CHAR};
int fun(char str[]){int words 0;char temp[100] { };strcat(temp,str);strcat(temp, );for(int i 1;i strlen(temp)-1;i){if(temp[i] ! temp[i-1] ){words ;}}return words;
}
int main(){char * p i am a b;printf(%d,fun(p));
}