So, my task is to reflect image pixel by pixel to make a mirror image. Here is my original code for the function

void reflect(int height, int width, RGBTRIPLE image[height][width])
int tempr, tempg, tempb;
for (int i = 0; i<height; i++)
    for (int j = 0; j<width; j++)
        tempr= image[i][j].rgbtRed;
        tempg= image[i][j].rgbtGreen;
        tempb = image[i][j].rgbtBlue;



The problem is that code seems to work fine but just in the first row. For some reason the loop for i doesn't work. In another discussion i saw the advice not to divide pixels for rgb but just swap them. It did't work out, cause the compiler says that I cannot assign struct to int. Tried to add another i++ somewhere in the code, just to make it work in any way, but still, only mistakes. I rewrote it one more time just to be sure, but the result is the same. Can you help me and tell, what i dont see here? I also asked the same question in stackoverflow, but didn't find help there.

One more thing that i had to mention. When i use the debugger, it says "The project settings file (.c9/project.settings ) was updated outside the IDE. If you did not make the changes we suggest reviewing the file before accepting. Do you want to accept the new settings?" and the code that was changed is

"@name": null, "@pid": null, "@proxy": null, "@runner": null to: "@name": "output", "@pid": 6813, "@proxy": 6894, "@runner": "GDBMonitor"

I don't know is it relevant

1 Answer 1


The problem is that you are decreasing the width. Instead of using width - 1, use width - j - 1. Eliminate the width--; line at the end of the inner loop. Also, instead of using j<width use j<(width/2).

Hope this helps. If it does then please check the tickmark.

  • Yeah, definitely helped. Thank you!
    – VVS232
    Nov 1, 2020 at 12:57

You must log in to answer this question.

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