且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法读取以逗号结尾的字符串

更新时间:2023-02-11 16:41:06

scanf函数需要一个指向初始数组的字节,当你正在阅读的字符串。所以不要使用&安培;当你作为参数传递的fscanf(FP,%[^,],名称)应该工作。

scanf expects a pointer to initial byte of an array, when you are reading a string. So dont use& when you are passing as an argument. fscanf(fp, "%[^,]", name) should work.

名称将在离pression使用时转换为指针。

name will be converted to a pointer when used in an expression.

http://pubs.opengroup.org/onlinepubs/009695399/functions/ fscanf.html