包含三个主要的文件:joefunction.h(c), m.c(主函数文件)
1. m.c
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "joefunction.h"
extern FILE *g_logFile;
int main(int argc, char *argv[])
{
char temp[16] = {0}, fname[20] = {0};
getTime(temp, TIME_FORMAT_FILENAME);
sprintf(fname, "%s.log", temp);
g_logFile = openFile(fname, "a+");
if(g_logFile)
{
int i;
for(i = 1; i <= 20; i++)
writeLog("%s()-%dL: CC-[%s%d]", __FILE__, __LINE__, "Hello world", i);
fclose(g_logFile);
}
return 0;
}
2. joefunction.h
// Author: Joe Black
// Time: 2011-4-5
// Note: This is a shared file which contains the most useful functions.
#include <stdio.h>
#define MAX_BUFSIZE 250
enum
{
TIME_FORMAT_DATETIME,
TIME_FORMAT_TIME,
TIME_FORMAT_DATE,
TIME_FORMAT_FIL