title: How to check if a file exists in C from user input
body: <p>I'm a complete noob to C and I wondered why if I take a user input why it wont find the file but when I hard code it using:</p>
  
  <pre><code>const char * fn = "/Users/james/Documents/test.rtf";
  </code></pre>
  
  <p>It seems to work fine?</p>
  
  <pre><code>char text[100];
  fputs("File location: ", stdout);
  fflush(stdout); 
  fgets(text, sizeof text, stdin);
  
  FILE *fp = fopen(text,"r");
  if( fp ) {
      printf("\nFile Exists");
      fclose(fp);
  } else {
      printf("\nFiles doesn't exist");
  }
  </code></pre>
  
  <p>Any help would be awesome, or just a point to some online source that I have clearly not been able to find.
  :)</p>