Hello guys,
I have this code snippet below and it crashes during the assignment in 'str', a dynamic allocation.
char *str;
int file_size;
FILE *fptr;
if (!(fptr = fopen(filename, "r"))) goto error1;
if ((fseek(fptr, 0L, SEEK_END) != 0)) goto error2;
if (!(file_size=ftell(fptr))) goto error2;
if ((fseek(fptr, 0L, SEEK_SET) != 0)) goto error2;
str = (char*)malloc(file_size+1);
if (fread(str, file_size, 1, fptr) != 1) {
free(str);
goto error2;
}
str[file_size] = '\0';
fclose(fptr);
Can somebody help me? I am using ARM.
edit : file_size is non-zero, non-negative less-140 value This actually works on my intel pc, but not on arm machine.
Thanks, giantK