C语言编写输出工作日志测试程序

来源:互联网 发布:mac口红独角兽 编辑:程序博客网 时间:2024/04/29 06:28
#include <stdio.h>
#include <time.h>


#define LOG(s) do {    \
time_t t;          \
struct tm* ti;     \
time(&t);          \
ti=localtime(&t);  \
printf ("%s [%s:%d] %s\n",asctime(ti),__FILE__,__LINE__,s); \
}while(0)

void f()
{
LOG ("Enter f()..");
LOG ("Exit f()..");
}

int main ()
{
LOG("Enter main()..");

f();

LOG("Exit main()..");
return 0;

}


输出结果:

0 0