void trace_out(const char *fmt, ... ) {
static FILE *trace_file = 0L;
time_t now = time(0L);//returns the specified calendar time value
char date_string[23];//declaring character date string
strftime(date_string, 256, "%Y-%m-%d %H.%M.%S", localtime(&now));//format of the time and date string
if (!trace_file) {
trace_file = fopen("trace.txt", "a+");
//trace file, provides output window for debugging
//if trace file detected open file
if (!trace_file)
return;
}
//required ato access variable arguement lists
va_list v;
va_start(v, fmt);
fprintf(trace_file, "%s |", date_string);//prints the data to a date string format
vfprintf(trace_file, fmt, v);//writes the formatted output to the trace file
fputc('\n', trace_file);//wites the characters to the stream
fflush(trace_file);//flushes the stream
}