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);
I am getting Debug Assertion Failed at fread(). Why?
MSVC2010, Windows-7-32 bit
You should first allocate sufficient amount of memory to the
bufferPointerby usingmalloc. Then you can usefreadto read from the file into that buffer.