I'm having a problem to read a file and put have all the content in a unsigned char pointer. All the content of the file is there, the problem is that it also adds some garbage at the end of the file. Here is the code:
I hope any of you can help me. Thanks.Code:unsigned char* ReadVPfile(char *filename)
{
FILE * file;
long vpfileSize;
file=fopen(filename, "rb");
if(!file)
return false;
fseek(file, 0, SEEK_END);
vpfileSize = ftell(file);
rewind(file);
//allocate memory
unsigned char * vpfileText=new unsigned char[vpfileSize];
if(!vpfileText)
return false;
fread(vpfileText, 1, vpfileSize, file);
return vpfileText;
}