我正在尝试运行一些代码,但fflush()
出现错误:
Invalid file descriptor. File possibly closed by a different thread
这是代码的相关部分:
fhandle = fopen("dbfile.bin", "rbc");
/* There is a valid dbfile.bin file - get file size */
_fstat(_fileno(fhandle), &file_stat);
printf("dbfile.bin size = %d\n", file_stat.st_size);
g_tpd_list = (tpd_list*)calloc(1, file_stat.st_size);
if (!g_tpd_list)
{
rc = MEMORY_ERROR;
}
else
{
fread(g_tpd_list, file_stat.st_size, 1, fhandle);
fflush(fhandle);
fclose(fhandle);
}