title: Rotating a PPM Image 90 degrees
body: <p>I need help rotating a PPM image in C. The rotate function is supposed to rotate the image of a previously read in PPM image 90 degrees to the right. The code will be posted below. I need help with the rotate() function. </p>
  
  <p>The signature of the function is:</p>
  
  <pre><code>void rotate(pixel_t *image, int x, int y)
  </code></pre>
  
  <p>X is the width of the image and Y is the height.</p>
  
  <p>Here is a look at how I accomplished some other PPM manipulations in this program:</p>
  
  <pre><code>void grayscale(pixel_t *image, int x, int y)
  {
      int i, average = 0;
      for (i = 0; i &lt; x*y; i++)
      {
          average = (image[i].r + image[i].g + image[i].b) / 3;
          printf("%c%c%c", average, average, average);
      }
  }
  
  void flipImage(pixel_t *image, int x, int y)
  {
      int r, c, i;
      for (c = y-1; c &gt;= 0; c--)
      {
          for (r = 0; r &lt; x; r++)
          {
              i = (c * x) + r;
              printf("%c%c%c", image[i].r, image[i].g, image[i].b);
          }
      }
  }
  </code></pre>
  
  <p>This is what I have so far:</p>
  
  <pre><code>void rotate(pixel_t *image, int x, int y)
  {
      int r, c;
      for (r = 0; r &lt; x; r++)
      {
           for (c = 0; c &lt; y; r++)
           {
               printf("%c%c%c", image[c].r, image[c].g, image[c].b);
           }
      }
  }
  </code></pre>