I have managed to finish but i have some queries regarding how fwrite exactly works. If you are new to pset4, the intention of my code is to fwrite the content of triple n times after i have fread triple.
for (int k=0; k<n; k++)
{
// write RGB triple to outfile
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
Versus
fwrite(&triple, sizeof(RGBTRIPLE), n, outptr);
However, only the former method works. Why so? Any help is appreciated!