STDIN(3POSIX)
π STDIN(3POSIX) π
okay bestie, welcome to the POSIX Programmer's Manual, the one and only. this page is literally about stderr, stdin, and stdout, and honestly? they run your entire life, you just don't know it yet. let's get into it π«Ά
πΈ PROLOG πΈ
so like, real talk first: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ β so if you're on Linux, go consult the corresponding Linux manual page for the actual deets on Linux behavior. and also? the interface might not even be implemented on Linux at all. not me warning you twice π. just check, okay?
β¨ NAME β¨
stderr, stdin, stdout β the standard I/O streams. the holy trinity. the main characters. π
π SYNOPSIS π
#include <stdio.h>
extern FILE *stderr, *stdin, *stdout;
look at them. three little pointers. iconic.
π DESCRIPTION π
so the functionality described on this reference page is aligned with the ISO C standard. and if there's any conflict between the requirements described here and the ISO C standard? that's unintentional, bestie, no drama intended. this volume of POSIX.1β2017 defers to the ISO C standard, periodt.
okay now the actual tea β:
a file with associated buffering is called a stream, and it's declared to be a pointer to a defined type FILE. the fopen() function shall create certain descriptive data for a stream and return a pointer to designate the stream in all further transactions. and normally? there are three open streams with constant pointers declared in the <stdio.h> header, and they're associated with the standard open files. three besties, forever linked.
at program start-up, three streams shall be predefined and need not be opened explicitly:
- standard input β for reading conventional input
- standard output β for writing conventional output
- standard error β for writing diagnostic output
and here's the buffering lore you need to know: when opened, the standard error stream is not fully buffered. the standard input and standard output streams are fully buffered if and only if the stream can be determined not to refer to an interactive device. yes, "if and only if" β that's a real logic gate, not a vibe. π§
the following symbolic values in <unistd.h> define the file descriptors that shall be associated with the C-language stdin, stdout, and stderr when the application is started:
STDIN_FILENOβ standard input value,stdin. its value is0.STDOUT_FILENOβ standard output value,stdout. its value is1.STDERR_FILENOβ standard error value,stderr. its value is2.
zero, one, two. that's it. that's the whole numeric identity crisis. π₯
and one more thing: the stderr stream is expected to be open for reading and writing. both. she contains multitudes. π
β RETURN VALUE β
None. nothing. nada. it returns absolutely nothing, and honestly? relatable.
π ERRORS π
no errors are defined. zero. none. flawless behavior, we love to see it. β¨
heads up: the following sections are informative. that's the official word, not me being shady.
π¦ EXAMPLES π¦
None. (yes, really. the examples section said "no thoughts, head empty." π)
π APPLICATION USAGE π
None. moving on bestie, nothing to see here.
π RATIONALE π
None. the reasoning is simply vibes. (fr fr, that's what it says.)
π FUTURE DIRECTIONS π
None. the future is unwritten, and this page is not about to speculate. π
π«Ά SEE ALSO π«Ά
go read these next, they're all in the same friend group:
fclose()feof()ferror()fileno()fopen()fprintf()fread()fscanf()fseek()getc()gets()popen()putc()puts()read()setbuf()setvbuf()tmpfile()ungetc()vfprintf()
also the Base Definitions volume of POSIX.1β2017: <stdio.h>, <unistd.h> β the header files themselves, the origin stories. π
π COPYRIGHT π
okay this part is long but it matters, so here it is in full:
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
so basically: if this page and the official Standard disagree, the Standard wins. no cap. the Standard is the main character here. π
and that's the whole page, bestie!! this was brought to you by IEEE/The Open Group, 2017, and the page itself is STDIN(3POSIX) β mwah, take care of your streams, they take care of you πβ¨ππ¦
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms