#include <time.h>
size_t strftime(char *s, size_t maxsize, const char *format, struct tm *timeptr);
01 #include <time.h>
02 #include <stdio.h>
03 #include <stdlib.h>
04 #include <string.h>
05
06 int main()
07 {
08 struct tm *tm_ptr, timestruct;
09 time_t the_time;
10 char buf[256];
11 char *result;
12
13 (void)time(&the_time);
14 tm_ptr = localtime(&the_time);
15 strftime(buf, 256, "%A %d %B, %I:%S %p", tm_ptr);
16
17 printf("strftime gives: %s\n", buf);
18 exit(0)
19 }
[root@localhost C]# ./strftime.exe
strftime gives: Saturday 21 February, 09:58 AM
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |