|
-
September 12th, 2001, 11:41 AM
#1
strftime() is not functioning for me...
the following code is used:
char strtime[15];
time_t tms;
time(&tms);
printf("\n %s",ctime(&tms));
strftime(strtime,9,"%m",&tms);
printf("\n %s",strtime);
The expected output from the second printf is 09 when run on September. But some wrong value is printed. I m using DIGITAL unix.
Please help me to resolve
-shinto
-
September 13th, 2001, 11:09 AM
#2
Re: strftime() is not functioning for me...
Use localtime or gmtime to convert tmt variable to tm type.
#include <time.h>
#include <stdio.h>
void main()
{
char strtime[15];
time_t tms;
time(&tms);
tm *ptm = localtime(&tms);
strftime(strtime, 9,"%m",ptm);
printf("\n %s",strtime);
}
Please - rate answer if it helped you
It gives me inspiration when I see myself in the top list =)
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
[email protected] | ICQ:57404554 | http://soukhov.com
Member of Russian Software Developer Network http://rsdn.ru
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|