strstr函數
char* src = "123.txt";
char *p = strstr(src, ".");
print(p) //.txt
//如果要得到txt,則移動指針
p++;
print(p) //txt
//切割可能存在多個切割字符的情況(這種情況,我試了下分割"\\"不行,主要是包含方法charContainsToChar不起作用)
char* src = "123..456.txt";
char *p = strstr(src, ".");
print(p) //.456.txt
while (charContainsToChar(p, point) > 0){ //判斷切割完成,是否還包含點,如果包含,則繼續切割。
p = strstr(p, ".");
p++;
}
print(p) //txt
改進版:
char *p = strstr(values[0], "\\"); char *p1; p1 = strstr(p, "\\"); printf("value:%s\n", p); //.456.txt' while (p1){ //判斷切割完成,是否還包含點,如果包含,則繼續切割。 p = strstr(p, "\\"); p++; p1 = strstr(p, "\\"); } printf("value:%s\n", p); //txt