I am trying to generate some files depends on the time of creation (execution)
I got the time stamp as example as the following:
/* ctime example */
#include <stdio.h>
#include <time.h>
int main ()
{
time_t rawtime;
time ( &rawtime );
printf ( "The current local time is: %s", ctime (&rawtime) );
return 0;
}
And I have written a simple program that will generate a file
//include this file for cout
#include <iostream.h>
#include <stdio.h>
#include <time.h>
using namespace std;
int main() {
FILE *file=NULL;
time_t rawtime;
time ( &rawtime );
file = fopen ( "TESTOUT.txt", "w"); // how to name my file with date and time
fprintf (file, "ABCDEFGHIJK");
return 0;
}
My problem is, how to name my file with date and time like:
TESTOUT001.txt
TESTOUT002.txt
TESTOUT003.txt
TESTOUT004.txt
TESTOUT005.txt
etc
or
TESTOUT04-Jun-08.txt
TESTOUT05-Jun-08.txt
TESTOUT06-Jun-08.txt
etc
Most idealy would be 001->> 999 or Time as name for me?
Please let me know how to combine those 2 piece of code together?
thank you
Last edited on
Thanks for the info,
Does it mean i need to put my XXX.txt name as string?
Because I am aiming to generate my txt file like the following
//time day month year.txt
1600-04Jun08.txt
1601-04Jun08.txt
1602-04Jun08.txt
1603-04Jun08.txt
Anyone know how to combine them?
Can I add like:
strftime+ ".txt" ??
right?
Actually you can put the ".txt" right in the strftime() format string.