ne*****@gmail.com wrote:
How can I get the current timestamp ?
You want to read up on the header ctime (or the header time.h, which puts
the stuff into global namespace). It defines all the standard types and
functions that deal with time. Here is a code snippet:
#include <ctime>
#include <iostream>
int main ( void ) {
std::time_t now;
std::time ( &now );
std::cout << asctime( std::gmtime( &now ) ) << '\n';
std::cout << asctime( std::localtime( &now ) ) << '\n';
std::cout << ctime( &now ) << '\n';
}
>
Bart wrote:
>ne*****@gmail.com wrote:
How can I make the filename variable, by appending the current
timestamp to file, instead of following static file name:
ofstream SaveFile("output.txt");
example something like:
"output_<currenttimestamp>.txt"
#include <sstream>
...
std::stringstream stream;
stream << "output_" << currenttimestamp << ".txt" << std::flush;
std::ofstream SaveFile(stream.str().c_str());
Ah, and please do not top-post: it is frowned upon in this group. (That's a
cultural thing, you will get better responses and friendlier replies if you
adjust. The local regulars seem to feel quite strongly about it.)
Best
Kai-Uwe Bux