我对c很陌生,需要将“ / w / x:y ///// z”的char *除以“ /”或“:”分成一个char数组,这样才能得到输出“”,“ w”,“ x”,“ y”,“”,“”,“”,“”,“ z”,NULL
int i;
int j;
int len = strlen(self);
int l = strlen(delim);
int cont;
int count = 0;
char* self = {"/w/x:y////z"};
char* delim = {"/:"};
for (j = 0; j < l; j++) {
for (i = 0; i < len; i++) {
if (self[i] == delim[j]) {
count +=1;
}
}
}
count += 1;
到目前为止,我已经计算出需要删除多少个字符,并且我知道我需要使用strtok。
任何帮助将不胜感激!预先谢谢你:)