J
junky_fellow
Hi,
I want to define a function log_file(), that would print the
formatted message to stdout if the FILE pointer passed is NULL else
print the formatted output to the file corresponding to FILE*.
For eg.
extern FILE *fp;
int main(void)
{
int n1=0;
int n2=100;
log_file(fp, "SOME MESSAGE n1=%d n2=%d\n", n1, n2);
}
I want that, log_file() should print the formatted output to stdout,
in case fp is NULL, else
print the output to the corresponding file.
Can some one please help ? I tried my best, but could not find any
solution.
thanks a lot for any help.
I want to define a function log_file(), that would print the
formatted message to stdout if the FILE pointer passed is NULL else
print the formatted output to the file corresponding to FILE*.
For eg.
extern FILE *fp;
int main(void)
{
int n1=0;
int n2=100;
log_file(fp, "SOME MESSAGE n1=%d n2=%d\n", n1, n2);
}
I want that, log_file() should print the formatted output to stdout,
in case fp is NULL, else
print the output to the corresponding file.
Can some one please help ? I tried my best, but could not find any
solution.
thanks a lot for any help.