error in my function "write_log"# Unix - 噫吁兮,危乎高哉
h*c
1 楼
I write a function "write_log" to log some message:
void write_log (FILE *fp_log, char *format, ...)
{
time_t tm;
va_list vl;
va_start(vl, format);
time(&tm);
printf("%s, pid:%d, ", cut_newline(ctime(&tm)),
(int)getpid());
printf(format, vl);
fprintf(fp_log, "%s, pid:%d, ",
cut_newline(ctime(&tm)), (int)getpid());
fprintf(fp_log, format, vl);
va_end(vl);
fflush(fp_log);
}
I call the function with : w
void write_log (FILE *fp_log, char *format, ...)
{
time_t tm;
va_list vl;
va_start(vl, format);
time(&tm);
printf("%s, pid:%d, ", cut_newline(ctime(&tm)),
(int)getpid());
printf(format, vl);
fprintf(fp_log, "%s, pid:%d, ",
cut_newline(ctime(&tm)), (int)getpid());
fprintf(fp_log, format, vl);
va_end(vl);
fflush(fp_log);
}
I call the function with : w