title: How do i check if a file is empty in C?
body: <p>I'm importing a txtfile into my file, how do i check if the input file is blank. </p>
  
  <p>I already check if it cannot read the input. This is what i have so far:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  
  int main (int argc, char *argv[]){
  
  // argv[1] will contain the file name input. 
  
  FILE *file = fopen(argv[1], "r");
  
  // need to make sure the file is not empty, error case. 
  
  if (file == NULL){
      printf("error");
      exit(0);
  }
   // if the file is empty, print an empty line.
  
  int size = ftell(file); // see if file is empty (size 0)
  if (size == 0){
      printf("\n");
  }
  printf("%d",size);
  </code></pre>
  
  <p>the size checking obviously does not work because i put in a few numbers and the size is still 0. any suggestions?</p>