Please preserve some context when posting replies.
"milkyway" <d0******@hotmail.com> wrote:
[ I would like to create a filename where the name of the file is:
ERRORS_MMDDYYYY_HHMMSS. ]
Thanks but are there any sample programs of how to use this lying
around?
A quick and dirty demo program:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define FILENAMELEN 23
int main( void )
{
char filename[FILENAMELEN];
time_t curtime;
struct tm *loctimep;
curtime = time( NULL );
if ( curtime == -1 )
{
fputs( "Calendar time not available\n", stderr );
exit( EXIT_FAILURE );
}
loctimep = localtime( &curtime );
if ( loctimep == NULL )
{
fputs( "Time conversion error\n", stderr );
exit( EXIT_FAILURE );
}
if ( strftime( filename, FILENAMELEN,
"ERRORS_%m%d%Y_%H%M%S", loctimep ) == 0 )
{
fputs( "Generated filename too long\n", stderr );
exit( EXIT_FAILURE );
}
printf( "Generated filename: %s\n", filename );
exit( EXIT_SUCCESS );
}
HTH
BEst regards
--
Irrwahn Grausewitz (ir*******@freenet.de)
welcome to clc :
http://www.ungerhu.com/jxh/clc.welcome.txt
clc faq-list :
http://www.faqs.org/faqs/C-faq/faq/
clc frequent answers:
http://benpfaff.org/writings/clc