title: Using a char array as the file name in C with fopen()
body: <p>I'm writing a program in C designed to allow a user to input the name of a file so that the program can read the contents of that file. The input must be in the format "/i:", which means that I have to strip off the first three characters to obtain the file name.</p>
  
  <p>I'm storing the file name in an array of characters with a preset length (because I don't know how long of a file name the user will input). The commands I'm using are:</p>
  
  <pre><code>achBaseOutput[100];
  FILE * InputFile
  
  //Instruct users on input
  
  fgets(achBaseOutput, 100, stdin);
  
  //Strips first three characters, scoots file name to start at achBaseOutput[0]
  
  InputFile = fopen(achBaseOutput, "r");
  </code></pre>
  
  <p>When I execute the code, I get an error box that says:</p>
  
  <pre><code>Debug Assertion Failed!
  File: fgets.c
  Line 57
  Expression: (str != NULL)
  </code></pre>
  
  <p>Unfortunately, the input format of the file name isn't up to me, so I can't change the /i: formatting for the input.</p>
  
  <p>How can I format the input string so that fopen accepts it as a valid argument?</p>