我正在用';'將字符串拆分爲標記。但是我有一個問題,例如一些標記是空的/空的; 123; 123132 ;;; 232; 232323 ;;;; 1; 所以我不能使用strtok becasuse合併鄰接分隔符。我看到您發佈此解決方案:我如何將一個字符串拆分爲'&'的標記
include <string.h>
char *data = "this&&that&other";
char *next;
char *curr = data;
while ((next = strchr(curr, '&')) != NULL) {
/* process curr to next-1 */
curr = next + 1;
}
/* process the remaining string (the last token) */
但我不理解,因爲當我做下1獲得firts值我只得到了價值並非所有的整體價值的firts字。 你能幫助我嗎?,你有任何想法如何分裂這個? 我是C ansi的程序員。我在另一篇文章中看到存在一個strsep函數,這似乎正是我需要的,但在C ansi庫中,這個函數不包含在內。 謝謝,對不起,我的英語:)
OK了很多感謝它的工作原理。 –