title: Assigning integer values from a file to an array using fgetc()
body: <p>I would like to get the numeric values from a .csv file and store them in an array. My attempt can be seen here:</p>
  
  <pre><code>FILE *ifp;
  
  ifp = fopen(DIREC,"r");
  if(ifp == NULL){
          fprintf(stderr,"Input file not read.\n");
          exit(1);
      }
  
  int rows = 0;
  int columns = 0;
  
  rows = readParts(ifp);
  fseek(ifp, 0, SEEK_SET);
  columns = readConfigs(ifp);
  fseek(ifp, 0, SEEK_SET);
  char arr[rows][columns];
  arr[rows][columns] = malloc(sizeof(int)*rows*columns);
  
  for (int i=0; i &lt; rows; ++i){
          while(!feof(ifp)){
              int count = 0;
              int c = fgetc(ifp);
  
              if(c == '\n'){
                  break;
              }
              if(isdigit(c)){
                  arr[i][count] = c;
                  count++;
              }
          }
      }
  printf("First entry: %d", arr[0][0]);
  
  fclose(ifp);
  </code></pre>
  
  <p>However, I am having issues with using <code>fgetc()</code> to read the integer values. I know it's grabbing the numbers as doing <code>printf("%c",c);</code> returns the correct results. However, when assigning <code>c</code> to <code>arr</code>, I am not assigning the correct value as <code>fgetc()</code> does not return the actual character value. I tried casting <code>(int) c</code>, but it did not change anything. I have looked into <code>fnscanf()</code>, but I am not sure how this would work since my .csv file also contains non-numerics. Is there a proper way to assign integer values to an array using <code>fgetc()</code>?</p>