相关疑难解决方法(0)

用scanf读取逗号分隔的输入

我有以下输入:

AG23,VU,Blablublablu,8
IE22,VU,FooBlaFooBlaFoo,3
and so on...
Run Code Online (Sandbox Code Playgroud)

我希望它使用像这样的代码"解析"scanf:

char sem[5];
char type[5];
char title[80];
int value;

while(scanf("%s,%s,%s,%d", sem, type, title, &value) == 4) {
 //do something with the read line values
}
Run Code Online (Sandbox Code Playgroud)

但代码的执行给了我:illegale instruction 你会如何读取这样的逗号分隔文件?

c csv scanf

14
推荐指数
1
解决办法
5万
查看次数

标签 统计

c ×1

csv ×1

scanf ×1