can anyone please tell me what the difference is beetween fread and fwrite and why do we have to fread smthg before we actually fwrite it into a file?
// read RGB triple from infile fread(&triple, sizeof(RGBTRIPLE), 1, inptr); // write RGB triple to outfile fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
Fread reads from inptr and stores that into &triple and fwrite reads from outptr and stores that into &triple as well, right?
So I already stored the bits into &triple with fread, why do I have to do the same thing with fwrite? In this example, fwrite writes from outptr, althought that is just an empty file we have opened so what can it possibly write into &triple when there is nothing in the file?
I'm just confused, can anybody please explain?