我得到了一个分割错误的错误,而试图使用fscanf从一个文件读取到一个字符串,任何帮助将非常感谢。
int main()
{
char temp[100];
FILE *fp = fopen("test.txt", "r");
if (fp == NULL)
{
printf("error");
}
memset(temp, 0, strlen(temp));
while (fscanf(fp,"%s", temp)==1)
{
}
return 0;
}发布于 2016-11-15 16:52:35
在对strlen(temp)的调用中,temp有未定义的内容。
相反,使用char temp[100] = {0};,而根本不使用memset。
https://stackoverflow.com/questions/40615359
复制相似问题