调试断言在FREAD失败() [英] Debug assertion failed at fread()

查看:162
本文介绍了调试断言在FREAD失败()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TEST.bin,烧写的大小为7,01,760字节。我想从这个文件作为一个缓冲区bufferPointer短阅读的日期。

The size of the test.bin is 7,01,760 bytes. I am trying to read date from this file as "short" in a buffer bufferPointer.

short * bufferPointer=NULL; 
// ==> ANSWER WAS ADDING: bufferPointer = ( short*)malloc(350880); <==
FILE *fp=fopen(" test.bin","rb");
fread(bufferPointer,sizeof(short),350880 ,fp); 
fclose(fp);

我正在调试断言失败在FREAD()。为什么?

I am getting Debug Assertion Failed at fread(). Why?

MSVC2010,Windows的7-32位

MSVC2010, Windows-7-32 bit

推荐答案

您应先用分配的内存到 bufferPointer 足够的量的malloc 。然后你可以使用 FREAD 从文件到该缓冲区中读取。

You should first allocate sufficient amount of memory to the bufferPointer by using malloc. Then you can use fread to read from the file into that buffer.

这篇关于调试断言在FREAD失败()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆