I am trying to read a binary file:
I can't see what is wrong with the code but the char array "ret" is not getting the values from my input file.
FILE *fl = fopen("dta.bin", "rb");
if ( (fopen("data.bin", "rb" )) == NULL)
printf("input file not found");
fseek(fl, 0, SEEK_END);
long len = ftell(fl);//get length of file
char *ret = (char*) malloc(len);
if(ret == NULL)
printf("\nInsufficient memory to read file\n");
fseek(fl, 0, SEEK_SET);
//Read data from file into array
fread(ret, 1, len, fl);
printf ("size of array: %i", sizeof(ret));
printf ("\nlength of file: %i", len);
The output says:
"size of array:4
length of file: 102727488"
when they should be the same length.