CPlay/time.c
2025-05-12 12:05:55 +02:00

24 lines
457 B
C

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
char *out = malloc(200);
struct tm *tmp;
time_t t = time(NULL);
tmp = localtime(&t);
if (tmp == NULL) {
perror("localtime");
exit(EXIT_FAILURE);
};
if (strftime(out, 200, "%s", tmp) == 0) {
fprintf(stderr, "strftime returned 0");
exit(EXIT_FAILURE);
}
printf("Result string is %s", out);
exit(EXIT_SUCCESS);
}