Hi
I need to change a file name and save it down in a different folder with the current date as determined by the system clock ie. <date>.txt the date format needs to be YYMMDD. Can anyone help me please.
struct tm *pnow ;
long tnow ; /* or time_t, see your doc */
FILE *stream ;
char fullname[80];
......
time( &tnow ) ;
pnow = localtime( &tnow ) ; // see difference with gmtime
// the area tm is internal at
// the system function
sprintf( fullname, "%s%02d%02d%02d.txt",
"mypath", // warning at / or \\ if unix or dos
pnow->tm_year - 1900, // warining at millenium bug ??
pnow->tm_mon + 1, // Jan = 0 ??
pnow->tm_day ) ;
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.