Please tell me where I am going wrong.
I have a file which I need to copy last n bytes to an array.
char *buffer = (char *)malloc(sizeof(char)*n);
size_t result = fread(buffer,sizeof(char)*n,1,outptr);
The value of result is 0.
Everything up till here in my code works right( I have checked all the values with gdb). I am freeing the buffer too after some lines.
n is userinputted. The output ptr is used as
FILE *outptr = fopen(outfile,"w")
//The outfile name is also user inputted and is checked to make sure it is a bmp file.
You are attempting to read from a file you have opened in write mode.
Change:
to: