Subj : Re: varargs(ish) To : comp.programming From : pete Date : Sun Aug 21 2005 02:52 pm pemo wrote: > > I'd like to write a C function that can > accept variable args *and* a fixed > arg that tells the function whether > to output to stdout and optionally, a file. > > So, I want something like this ... > > void out(int outputType, const char * format, ...) > { > switch(outputType) > { > case 1: > fprintf(logFile, format, ????); > > // Fall Through. > > case 2; > > printf(format, ????); > break; > > default: > break; > } > > The question is, what do I put for the ???? please!? I think you just want fprintf. int fprintf(FILE *stream, const char *format, ...); A call to fprintf with the first argument equal to stdout, is the same as a call to printf. If you want to write to a text file, use the FILE type pointer to the text file for the first argument instead. -- pete .