0

I've just successfully completed resize less. It took me a lot of time, but, final correction that I needed to make surprised me a lot. There was a huge mess of RGB triples when my fwrite function was like: fwrite(&newRow, sizeof(RGBTRIPLE), bi.biWidth, outptr); and when I wrote this line without '&' such as fwrite(newRow, sizeof(RGBTRIPLE), bi.biWidth, outptr); everything worked perfectly. Can someone explain the difference please ?

0

I'm going to assume that newRow was declared as a pointer? If that's the case, then &newRow is the address of the pointer itself (not what it points to), so trying to write to that would be incorrect.

2
  • Your assumption is correct and thanks for the answer. how does RGBTRIPLE triple; // read RGB triple from infile fread(&triple, sizeof(RGBTRIPLE), 1, inptr); // write RGB triple to outfile fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr); in copy.c work then ? – Ali Sarp Mestcioglu Jul 17 '18 at 22:55
  • triple in that example is an array, so &triple points to the array. – curiouskiwi Jul 18 '18 at 1:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .