我正在用';'将字符串拆分为标记。但是我有一个问题,例如一些标记是空的/空的; 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了很多感谢它的工作原理。 –