I am trying to write a function that allows me to write to the console and a file in C.
I have the following code but i realized that it does not allow me to append arguments (like printf).
#include <stdio.h>
int footprint (FILE *outfile, char inarray[]) {
printf("%s", inarray[]);
fprintf(outfile, "%s", inarray[]);
}
int main (int argc, char *argv[]) {
FILE *outfile;
char *mode = "a+";
char outputFilename[] = "/tmp/footprint.log";
outfile = fopen(outputFilename, mode);
char bigfoot[] = "It Smells!\n";
int howbad = 10;
footprint(outfile, "\n--------\n");
/* then i realized that i can't send the arguments to fn:footprints */
footprint(outfile, "%s %i",bigfoot, howbad); /* error here! I can't send bigfoot and howbad*/
return 0;
}
I'm stuck here. Any tips? For the arguments which I want to sent to function:footprints, it will consist of strings, chars and integers.
Are there other printf or fprintf fns that I can try to create a wrapper around?
Thanks and hope to hear ya'll responses.