title: Copying a struct's contents to another
body: <p>I am trying to copy a struct's contents into another struct of the same type.</p>
  
  <p>I would like to be able to change the values of one struct without it affecting the other later though.</p>
  
  <p>I am dealing with reading and editing PPM files. I have a struct:</p>
  
  <pre><code>typedef struct {
      char format[4];
      char comments[MAX_COMMENT_LENGTH];
      int width, height, maxColourValue;
      PPMPixel **pixels;
  } PPMImage;
  </code></pre>
  
  <p>And then I have a copy function to copy the values over but I get an error when assigning different fields.</p>
  
  <p>I am trying to copy the fields of newPPM into messagePPM.</p>
  
  <p>Error:</p>
  
  <pre><code>incompatible types when assigning to type 'char[4]' from type 'char *'
      messagePPM-&gt;format = newPPM-&gt;format;
  incompatible types when assigning to type 'char[100]' from type 'char *'
      messagePPM-&gt;comments = newPPM-&gt;comments;
  </code></pre>
  
  <p>Copy Function:</p>
  
  <pre><code>//A function to copy contents of one PPMImage to another
  void copyPPM(PPMImage *newPPM, PPMImage *messagePPM) {
  
      messagePPM-&gt;format = newPPM-&gt;format;
      messagePPM-&gt;comments = newPPM-&gt;comments;
      messagePPM-&gt;width = newPPM-&gt;width;
      messagePPM-&gt;height = newPPM-&gt;height;
      messagePPM-&gt;maxColourValue = newPPM-&gt;maxColourValue;
      messagePPM-&gt;pixels = newPPM-&gt;pixels;
  </code></pre>
  
  <p>}</p>
  
  <p>How do I fix my error?
  Will copying fields this way achieve what I am aiming for?</p>