title: Read data from a txt.file and print out its 2D array contents
body: <p>I need some help, I would like to print out information from a file (in characters) </p>
  
  <p>I decided to use a 2D array since the data looks something like this </p>
  
  <pre><code>0 0 . . . 
  0 0 . . . 
  . . . . . 
  . . . . . 
  . . . . . 
  </code></pre>
  
  <p>It seems that I cannot print them out with the code that I have prepared now</p>
  
  <p>please see below:</p>
  
  <pre><code>/* Read from file, pass on file contents to a 2D array, Print file contents from 2D array*/
  
  #include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  #define N 5
  
  
  //My proposed function to print an array with contents from a file
  void printboard(int **a, int n, int n);
  
  int main(int argc, char *argv[])
  {   
      char linestr[100];
      int board[N][N];
      int k;
      int h=0, l=0; 
      if(argc==2) //File should be called from the terminal hence working with argc &amp; argv
      {
          FILE *fp;
          fp = fopen(argv[1], "r");
  
  
       if(fp == NULL) 
          {
              printf("Error, can't open '%s' file!!!\n", argv[1]);
              return -1;
          }
      while (fgets(linestr,sizeof linestr, fp) != NULL)
          for(k=0; k&lt;strlen(linestr); k++)
          {
              if (linestr[k]!='\n')
              {
                  board[h][l]=(int)linestr[k];
                  l++;
  
  
              }
              h++;
              l=0;
          }
          fclose(fp);
      }
      printboard(board,h,l);
  
  return 0;
  }
  
  void printboard(int **a, int n, int n)
  {
      int i, j;
      for (i=0; i&lt; N; i++)
      {
          for (j=0; j&lt; N; j++)
          {
              printf("%c", a[i][j]);
          }
          printf("\n");
      }
  
  
  }
  </code></pre>
  
  <p>I have very basic knowledge in C and only began coding 1.5 months ago. Is there any advice from the community how I can fix this or do it better? The aim is to print contents of a file in a 2D array format. I would really like to have the data work with 2D array because I need to work further on it to move the '0' in a game called Peg Solitaire.</p>