#include <stdio.h>
#include <time.h>
#include <string.h>
void
print_log(char *arg)
{
time_t t = time(NULL);
char *str = ctime(&t);
str[strlen(str) - 1] = 0;
printf("[%s] %s\n", str, arg);
}
Which prints something like:
$ ./example
[Tue Nov 17 21:51:41 2015] this is just a test
No comments:
Post a Comment