[坑]fread的模式
2021/06
23
22:06
FILE* fp = NULL;
char* buff = NULL;
fopen_s(&fp, filename, "r");
if (fp != NULL)
{
fseek(fp, 0, SEEK_END);
long fileSize = ftell(fp);
fseek(fp, 0, SEEK_SET);
buff = (char*)malloc(fileSize + 1);
memset(buff, 0, fileSize + 1);
size_t rdsz = fread(buff, 1, fileSize, fp);
fclose(fp);
if (rdsz != fileSize)
{
// 此处读文本文件会报错
必须要使用
fopen_s(&fp, filename, “rb”); 的二进制模式才行
CopyRights: The Post by BY-NC-SA For Authorization,Original If Not Noted,Reprint Please Indicate From 老刘@开发笔记
Post Link: [坑]fread的模式
Post Link: [坑]fread的模式