0

my code for reflect is this

void swap (RGBTRIPLE *a, RGBTRIPLE *b)
{
RGBTRIPLE temp=*a;
*a=*b;
*b=temp;

}


// Reflect image horizontally
void reflect(int height, int width, RGBTRIPLE image[height][width])
{
    
for (int i=0;i<height; i++) 
{ 
    for (int j=0;j<width/2;j++) 
    {
     
        swap(&image[i][j],&image[i][width - (j + 1)]);
      
        
    }
}
    
    return;
}

When I run the code I get runtime error index -1 out of bounds for type 'RGBTRIPLE [width]'. Kindly Troubleshoot

2
  • Your code works perfectly for me.
    – Sentox
    Nov 9 '20 at 3:56
  • it worked thanks
    – Cooldude
    Nov 16 '20 at 13:33

You must log in to answer this question.

Browse other questions tagged .