CKTIS / C
stderr — standard error stream
stderr is a macro from <stdio.h> identifying the standard diagnostic stream, separate from stdout.
Version: C23; repository compiler flag, production runtime not attested
Syntax
#include <stdio.h>
/* stderr: macro expanding to an expression of type FILE * */
fputs("Diagnostic\n", stderr);The <stdio.h> macro stderr expands to an expression of type FILE *. In a hosted environment, it identifies a standard text stream opened at program startup for diagnostics; stdout is for ordinary results.
Initially, stderr is not fully buffered. This does not guarantee that it is completely unbuffered. Do not assume messages always reach a screen, either.
Pass stderr to fputs or fprintf. The example checks writing and fflush for errors; printing a message alone does not set the program's termination status.
Examples
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
if (fputs("Diagnostic\n", stderr) == EOF) {
return EXIT_FAILURE;
}
if (fflush(stderr) == EOF) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.