【发布时间】:2014-03-20 07:15:35
【问题描述】:
我正在尝试读取配置文件中给出的接口列表。
char readList[3];
memset(readList,'\0',sizeof(readList));
fgets(linebuf, sizeof(linebuf),fp); //I get the file pointer(fp) without any error
sscanf(linebuf, "List %s, %s, %s \n",
&readList[0],
&readList[1],
&readList[2]);
假设配置文件的行是这样的 列出值1 值2 值3
我无法阅读此内容。有人可以告诉我这样做的正确语法吗?我在这里做错了什么。
【问题讨论】:
-
char是一个字符而不是字符串。您正在将 3 个字符串读入 3 个字符。