Here’s the GNU version of printf
… you can see it passing in stdout
to vfprintf
:
__printf (const char *format, ...)
{
va_list arg;
int done;
va_start (arg, format);
done = vfprintf (stdout, format, arg);
va_end (arg);
return done;
}
See here.
Here’s a link to vfprintf
… all the formatting ‘magic’ happens here.
The only thing that’s truly ‘different’ about these functions is that they use varargs to get at arguments in a variable length argument list. Other than that, they’re just traditional C. (This is in contrast to Pascal’s printf
equivalent, which is implemented with specific support in the compiler… at least it was back in the day.)