title: How to read an int array and check its x and y size
body: <p>I have a file that the 2 first numbers are the line and column count of an array. Then it may or may not have the correct size array in the following 'line' lines. That's what I need to do, read line by line of this array (in this file) and check if the line and column size match the ones passed at the beginning of the file.</p>
  
  <p>I tried using <code>fgetc</code> but if you have a number with more than 2 digits (like 10) it will treat as 1 and 0, not 10. I couldn't figure out how to use <code>fscanf</code> since when it reaches an end-of-line it simply goes to the next line, so I can't keep count of the array lines.</p>
  
  <p>Example using <code>fgetc</code>:</p>
  
  <pre><code>char t;
  while(1) {
      //pega um char
      t = fgetc(file);
  
  if(t == ' ') {
      continue;
  } else if(t == '\n') {
      //verifica se o num de colunas lido é igual ao passado no inicio do arquivo, se for incrementa a linha e zera as colunas
      if(j == y) {
          i++;
          j = 0;
          continue;
      } else {
          //se nao for igual, sai do programa
          return -1;
      }
  } else if(t == '0' || t == '1' || t == '6' || t == '7') {
  
  } else if(t == '2') {
      coordIni++;
  } else if(t == '3') {
      obj1++;
  } else if(t == '4') {
      obj2++;
  } else if(t == '5') {
      obj3++;
  } else if(t == '8') {
      item1++;
  } else if(t == '9') {
      item2++;
  } else {
      //usou algo maior q 9 ou menor q 0
      return -1;
  }
  
  mapa[i][j] = t - '0';
  j++;
  </code></pre>
  
  <p>}</p>
  
  <p>But as I said, in this case if the file has eg 10, it will read 1 then 0, and that can't happen.
  How can I solve that?</p>
  
  <p>Ex. input:</p>
  
  <p>Correct one:</p>
  
  <p>5 5</p>
  
  <p>1 1 1 1 1</p>
  
  <p>1 2 1 5 1</p>
  
  <p>1 0 1 0 1</p>
  
  <p>1 0 0 0 1</p>
  
  <p>1 1 1 1 1</p>
  
  <p>Incorrect:</p>
  
  <p>7 7</p>
  
  <p>1 1 1 1 1 1 1</p>
  
  <p>1 0 2 0 0 0 1</p>
  
  <p>1 1 1 1 1 1 1</p>
  
  <p>Just a heads-up, the newline between each line of the array is not present on the file, I don't know how to post array here, it was showing in a single line all the array here.</p>
  
  <p>Thanks</p>