[HUST CSE] fix fgets_tc.c (#7503)
这个文件里存在使用fopen函数后没有关闭文件fclose的问题,而且stream=NULL时是不需要fclose的
This commit is contained in:
parent
eb08036537
commit
b1415c4fc8
|
@ -19,15 +19,21 @@ static int fgets_entry(void)
|
||||||
fclose(stream);
|
fclose(stream);
|
||||||
|
|
||||||
stream = fopen("fopen_file.txt","r");
|
stream = fopen("fopen_file.txt","r");
|
||||||
|
if (stream == NULL)
|
||||||
|
{
|
||||||
|
perror("fopen fail");
|
||||||
|
ret = -1;
|
||||||
|
goto __exit;
|
||||||
|
}
|
||||||
fgets(gets, sizeof(gets), stream);
|
fgets(gets, sizeof(gets), stream);
|
||||||
|
|
||||||
if(strcmp(gets, data))
|
if(strcmp(gets, data))
|
||||||
{
|
{
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
fclose(stream);
|
||||||
|
|
||||||
__exit:
|
__exit:
|
||||||
fclose(stream);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue