What does it mean to write to stdout in C?

That means that you are printing output on the main output device for the session… whatever that may be. The user’s console, a tty session, a file or who knows what. What that device may be varies depending on how the program is being run and from where.

The following command will write to the standard output device (stdout)…

printf( "hello world\n" );

Which is just another way, in essence, of doing this…

fprintf( stdout, "hello world\n" );

In which case stdout is a pointer to a FILE stream that represents the default output device for the application. You could also use

fprintf( stderr, "that didn't go well\n" );

in which case you would be sending the output to the standard error output device for the application which may, or may not, be the same as stdout — as with stdoutstderr is a pointer to a FILE stream representing the default output device for error messages.

Leave a Comment