title: PPM scanning and printing
body: <p>I want to scan in documents from a file of type .ppm which are image files but follows the following data structure</p>
  
  <pre><code>P3
  4 4
  255
  255 255   0 255 255   0 255 255   0 255 255   0 
  255 255   0 255   0   0 128 128 128 255 255   0 
  255 255   0   0 255   0   0   0 255 255 255   0 
  255 255   0 255 255   0 255 255   0 255 255   0 
  </code></pre>
  
  <p>Every 3 integers mark a column so after the first 3 lines, this marks a pattern of a 4x4 table as indicated on the second line.</p>
  
  <p>My first step is to read in a file like this where the height and width can vary and then reprint it in the exact format using scanf and printf.</p>
  
  <p>My attempt at this is as follows:</p>
  
  <pre><code>scanf(" %d%d %d", &amp;width, &amp;height, &amp;depth);
  printf("P3\n%d %d\n %d\n", width, height, depth);
  
     while(scanf("%c", &amp;input) &gt;= 1) {
          for (int i = 0; i &lt; width; i++) {
              printf("%c %c %c ", input, input, input);
              for (int j = 0; j &lt; height; j++) {
                  printf("\n");
              }
          }
      }
  </code></pre>
  
  <p>Any idea what I am missing?</p>