你好我有行格式的文本文件
1|few ewf ew fewfew
我需要解析它,但我不知道怎么能从我不知道的第二个值中删除空格尾部。
到目前为止,这是我的segmentation fault
尝试
char* token1;
char* token2;
char* search = "|";
char* search2 = " "; // double space because string can contains single space
while (fgets(line, 150, f)) {
token1 = strtok(line, search);
token2 = strtok(search, search2); // <- segfault
//token2 = strtok(NULL, search); <- contains a lot of spaces in tail