title: Save data into a file: where the adress of the file is given by the user
body: <p>I ran a simulation for some data y1, y2,..yn and generate vectors w, mu. At each simulation these results are stored into a file, let us say (normally w and mu are very long vectors 10,000 entries) </p>
  
  <pre><code>/home/carlos/Documents/Results/w.txt
  /home/carlos/Documents/Results/mu.txt
  </code></pre>
  
  <p>But if I want to run my algorithm with other data set, and do not want to lose the previous results, I have to go directly into my C code and change (or move the w.txt, mu.txt to other file)</p>
  
  <pre><code>/home/carlos/Documents/Results/OtherData/w.txt
  /home/carlos/Documents/Results/OtherData/mu.txt
  </code></pre>
  
  <p>I do not want to go every time into my C code to change the address(or move again and again w.txt, mu.txt), I would like to just create a new folder with a name: OtherData and store the data there just giving the address </p>
  
  <pre><code>/home/carlos/Documents/Results/OtherData/
  </code></pre>
  
  <p>as an input for the code</p>
  
  <p>I did a very simplified example but it does not work, could somebody give me a hand?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  void main(char *dir){
    char dir_happy[100] = *dir, dir_sad[100]=*dir;
    FILE *ffile_happy, *ffile_sad;
  
    strcat(dir_happy, "/happy.txt");
    strcat(dir_sad, "/sad.txt");
  
    ffile_happy = fopen("dir_happy.txt", "w");
    ffile_sad = fopen("dir_sad.txt", "w");
  
    fprintf(ffile_happy, "Hello!, happy world\n");
    fprintf(ffile_sad, "Hello!, sad world\n");
  
    fclose(ffile_happy);
    fclose(ffile_sad);
  }
  </code></pre>