title: C program to read integers into an Array then print its it
body: <p>I am new to C programming and I have been trying to make a simple program that reads integers from a .txt file into an array then print it.
  The numbers in the file are arranged as follows:</p>
  
  <p>23</p>
  
  <p>44</p>
  
  <p>12</p>
  
  <p>41</p>
  
  <p>123</p>
  
  <p>And this is the code I have been trying:</p>
  
  <pre><code>void main()
  {
  FILE *fp;
  int num[100],i,j;
  fopen_s(&amp;fp, "C:/Users/User1/Desktop/NUI/fp.txt", "r");
  
  
  
  if (fp == NULL)
  {
      printf("Can't open file for reading.\n");
  }
  else
  {
      for (i = 0; i&lt;5; i = i + 1) {
          fscanf_s(fp, "%d", &amp;num[i]);
      }
  
  }
  for (j = 0; j&lt;5 ; j = j + 1) {
      printf("%d\n", num[j]);
  }
  fclose(fp);
  }
  </code></pre>
  
  <p>In the FOR LOOP I have to write i&lt;5 , j&lt;5 to set number of iterations.But I want to know of there is a way to make the loop recognise the final number automatically.
  (Something similar to char[i]!='\0' but for int array)</p>