dev/cpp/multithreading/time_test.c

30 lines
598 B
C
Raw Normal View History

#include <stdio.h>
#include <time.h>
#include <unistd.h>
int main(int argc, char * argv[])
{
//~ int i = 0;
//~ for ( i = 0; i < 10; i++ )
//~ {
//~ printf("%llu \n", (unsigned long long)time(NULL));
//~ sleep(1);
//~ }
printf("sizeof(ssize_t) = %lu\n", sizeof(ssize_t));
time_t now;
struct tm *ts;
char buf[80];
/* Get the current time */
now = time(NULL);
/* Format and print the time, "ddd yyyy-mm-dd hh:mm:ss zzz" */
ts = localtime(&now);
strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z", ts);
printf("%s\n", buf);
return 0;
}