未验证 提交 b1415c4f 编写于 作者: C chiehwarm 提交者: GitHub

[HUST CSE] fix fgets_tc.c (#7503)

这个文件里存在使用fopen函数后没有关闭文件fclose的问题,而且stream=NULL时是不需要fclose的
上级 eb080365
......@@ -19,15 +19,21 @@ static int fgets_entry(void)
fclose(stream);
stream = fopen("fopen_file.txt","r");
if (stream == NULL)
{
perror("fopen fail");
ret = -1;
goto __exit;
}
fgets(gets, sizeof(gets), stream);
if(strcmp(gets, data))
{
ret = -1;
}
fclose(stream);
__exit:
fclose(stream);
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册