title: C Storing Matrix in Array of Chars and Printing
body: <p>Hey all I am trying to store a matrix in an array of chars and then print it out.</p>
  
  <p>My code that I have written:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  int main() {
    int i;
    int j;
    int row=0;
    int col=0;
    int temp=0;
    char c;
    int array[3][2] = {{}};
    while((c=getchar()) !=EOF &amp;&amp; c!=10){
      if((c==getchar()) == '\n'){
        array[col++][row];
        break;
      }
      array[col][row++]=c;
    }
    for(i=0; i&lt;=2; i++){
      for(j=0; j&lt;=3; j++){
        printf("%c ", array[i][j]);
      }
      printf("\n");
    }
  }
  </code></pre>
  
  <p>Using a text file such as:</p>
  
  <pre><code>1 2 3 4
  5 6 7 8
  9 1 2 3
  </code></pre>
  
  <p>I would like to be able to print that back out to the user, however what my code outputs is: </p>
  
  <pre><code>1 2 3 4
  3 4 5 6
  5 6 7 8
  </code></pre>
  
  <p>I cannot figure out what is wrong with my code, some how I am off an iteration in one of my loops, or it has something to do with not handling new lines properly. Thanks!</p>