Happy new year all.
Leslie, you may also want to have a look to strftime(3) if you need fancy
formatting.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define STRMAX 64
int
main(int argc, char **argv) {
time_t now = time(NULL);
if (now == (time_t) -1 ) {
perror("time");
exit(1);
}
struct tm *now_tm = localtime(&now);
if (now_tm == NULL) {
perror("localtime");
exit(1);
}
char outstring[STRMAX];
size_t ret = strftime(outstring, STRMAX, "Today is %A, %B %d.", now_tm);
if (ret == 0) {
perror("failure in strftime");
exit(1);
}
printf("%s\n", outstring);
return 0;
}
_______________________________________________
mlug mailing list
[email protected]
https://listes.koumbit.net/cgi-bin/mailman/listinfo/mlug-listserv.mlug.ca