I'm working on the cs50 pset4 exercise filter, and I finished the grayscale filter and the sepia filter, and now I'm on the reflect filter. I'm supposed to reflect this image horizontally:

**NORMAL**

[![enter image description here](https://i.stack.imgur.com/t5kwy.png)](https://i.stack.imgur.com/t5kwy.png)

But all I get is this:

**REFLECT**

[![enter image description here](https://i.stack.imgur.com/awsK4.png)](https://i.stack.imgur.com/awsK4.png)

I don't know what's wrong. I tried to do it like in the video. In my code, i tried putting the right-side pixels into a temporary variable, then placing the left-side pixels into their place, then taking the right-side pixels out and putting them into the left-side pixel spot. Here's my code(reflect part only):

```c
// Reflect image horizontally
void reflect(int height, int width, RGBTRIPLE image[height][width])
{
    for (int j = 0; j < height;j++)
    {
    for (int i = 0; i < width/2;i++)
    {
        RGBTRIPLE temp = image[j][i];
       image[j][width - i] = image[i][j];
       temp = image[j][width - i];

    }
    }

    return;
}

```

Please help me understand. When I googled it, all I got was either something different or the answer to the whole exercise, which is just copy-pasting from google.

Thanks a lot,
Lost in code:)