Ich versuche, eine Funktion zu schreiben, die mich an die Konsole und eine Datei in CSchreiben in eine Datei und Konsole in C
ich den folgenden Code haben schreiben können, aber ich erkannte, dass es mir nicht erlauben, Argumente anhängen (wie 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;
}
Ich stecke hier fest. Irgendwelche Tipps? Für die Argumente, die ich senden möchte, um zu funktionieren: Fußabdrücke, wird es aus Strings, Zeichen und ganzen Zahlen bestehen.
Gibt es andere printf oder fprintf fns, die ich versuchen kann, einen Wrapper um zu erstellen?
Vielen Dank und hoffen, Ihre Antworten zu hören.
http://stackoverflow.com/questions/1719784/c-programming-forward-variable-argument-list See. – Bill