title: Creating a new file every time a programme is run in c
body: <p>I'm creating a programme that writes the results of a questionnaire to a .txt file and wondered if there was any way to create a new file with a new name every time the programme was run?</p>
  
  <pre><code> FILE *fp;
   fp = fopen("results.txt","w");
  </code></pre>
  
  <p>How can the file reults.txt be saved under a different name each time?</p>
  
  <p>so ive done the below which lets a user save the name of their results.</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
  
  printf("Please enter a filename to save your results to\n");
  
      char c;
      FILE *fp;
  
      if (argc &gt;= 2){
           fp = fopen(argv[1], "w");}
  
      while ((c = getchar()) != EOF)
      {
          putc(c, fp);
      }
  </code></pre>
  
  <p>but i get a core fault.</p>