title: How to implement a function to use out of its local scope?
body: <p>I'm working with images in C and OpenGL to show them in a window. I have a struct like this:</p>
  
  <pre><code>typedef struct imagemRGB ImagemRGB;
  struct imageRGB {
      int  width;        
      int height;        
      PixelRGB **pixel;
  };
  </code></pre>
  
  <p>Where <code>**pixel</code> is a matrix that represent each pixel and its color in the image. PixelRGB is a struct like this:</p>
  
  <pre><code>typedef unsigned char Byte;
  
  typedef Byte Boolean;
  
  /*-------------------------------------------------------------*/
  /* pixel True Color */
  /* http://en.wikipedia.org/wiki/True_Color#True_color_.2824-bit.29 */
  typedef struct pixelRGB PixelRGB;
  struct pixelRGB {
    Byte    red;         /* valor entre 0 e 255 */
    Byte    green;       /* valor entre 0 e 255 */
    Byte    blue;        /* valor entre 0 e 255*/
    Boolean visited;    /* TRUE ou FALSE */ 
  };
  </code></pre>
  
  <p>I have a function signature which is:</p>
  
  <pre><code>void copyImageRGB (ImageRGB *target, ImageRGB *origin);
  </code></pre>
  
  <p>This function is supposed to copy the image structure (<code>width</code>, <code>height</code> and each <code>pixel</code>) to the <code>target</code> so I can have the OriginalImage stored since the beginning;</p>
  
  <p>I'm implementing it with this code:</p>
  
  <pre><code>copyImageRGB (ImageRGB *target, ImageRGB *origin)
  {
  int i, j;
  
  target-&gt;width = origin-&gt;width;
  target-&gt;height = origin-&gt;height;
  for(i = 0; i &lt; origin-&gt;height; i++)
    for(j = 0; j &lt; origin-&gt;width; j++)
    {
      target-&gt;pixel[i][j].red = origin-&gt;pixel[i][j].red;
      target-&gt;pixel[i][j].blue = origin-&gt;pixel[i][j].blue;
      target-&gt;pixel[i][j].green = origin-&gt;pixel[i][j].green;
    }
  }
  </code></pre>
  
  <p>Bu I'm not sure it will work as expected in my <code>main</code> because its arguments are local variables. Am I right? How do I implement this function so that I can do: <code>copyImageRGB(target, originalImage);</code> in my <code>main</code>?</p>