Can the values of `stdin`,` stdout` and `stderr` be considered constant?
From the Ubuntu man page stdin(3)
:
extern FILE *stdout;
From the mingw64 file stdio.h
:
#define stdout (&__iob_func()[1])
Both assume that the value stdout
(pointer) cannot be considered constant.
Can I still rely on something like this:
FILE * stream;
// early after startup
stream = stdout;
// much later, far down the stack, in a different function
fprintf(stream, "%s", "fprintf(stream, \"");
+3
not-a-user
source
to share
1 answer
This is what the C11 standard ( §7.21.1-3 ) has to say (emphasis mine):
STDERR
STDIN
standard output
which are expressions like '' pointer to FILE that point to FILE objects associated with standard errors, input and output, respectively.
+2
DeiDei
source
to share