title: fgets() not working.in C?
body: <p>Edit: Deleted all but the main question.</p>
  
  <p>My program here is supposed to create a file at a specified directory, and write specified text to it. A correct file's path and content should look something like this:</p>
  
  <pre><code>Path: D:\test.txt
  Content: The printing succeeded.
  </code></pre>
  
  <p>For some reason, my code won't recognize the "path" variable. I don't know what I'm doing wrong here. The "text" variable works fine.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int main()
  {
  
  //Declaring variables
  char path[999];
  char text[999];
  FILE *fp;
  
  //prompting for path variable
  printf("Specify a file path.\n");
  fgets(path,999,stdin);
  printf(path);
  
  //prompting for the text variable.
  printf("What do you want to write?");
  fgets(text,999,stdin);
  printf(text);
  
  //opening and printing to file.
  //fp = fopen("D:\\test.txt", "w");
  fp = fopen(path, "w");
  fprintf(fp, text);
  fclose(fp);
  
  //test print to see that the program completed correctly.
  printf("\nThe printing has been done.");
  return 0;
  }
  </code></pre>
  
  <p>The thing I don't understand is that <code>fp = fopen("D:\\test.txt", "w");</code> works, but <code>fp = fopen(path, "w");</code> doesn't. I've tried putting in these different paths.:</p>
  
  <pre><code>D:\\test.txt
  D:\test.txt
  D\test.txt
  D\\test.txt
  </code></pre>