title: Pass system date and time as a filename in C++
body: <p>I wanted to make an Attendance system which would take system date and time as file name of the file for ex:
  this is how normally it is</p>
  
  <pre><code>int main () {
  time_t t = time(0);   // get time now
  struct tm * now = localtime( &amp; t );
  cout &lt;&lt; (now-&gt;tm_year + 1900) &lt;&lt; '-'
       &lt;&lt; (now-&gt;tm_mon + 1) &lt;&lt; '-'
       &lt;&lt;  now-&gt;tm_mday
       &lt;&lt; endl;
    ofstream myfile;
    myfile.open ("example.txt");
    myfile &lt;&lt; "Writing this to a file.\n";
    myfile.close();
    return 0;
  } 
  </code></pre>
  
  <p>but i want system date and time in place of example.txt
  i have calculated time by including ctime header file in the program above program is just example .</p>