STDIN(3P)

๐Ÿ’– STDIN(3P) โ€” bestie edition ๐Ÿ’–

okay so welcome to the POSIX Programmer's Manual, specifically the page for stdin, stdout, and stderr โ€” the three streams that literally run your whole life and you probably never think about them. this is STDIN(3P) from the POSIX Programmer's Manual, and we're gonna go through it together, no cap. ๐ŸŽ€


โœจ PROLOG โœจ

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 tea. or, honestly, the interface might not even be implemented on Linux at all. ๐Ÿซ 


๐ŸŒธ NAME ๐ŸŒธ

stderr, stdin, stdout โ€” standard I/O streams. the holy trinity. the main characters. ๐Ÿ‘‘


โœจ SYNOPSIS โœจ

#include <stdio.h>

extern FILE *stderr, *stdin, *stdout;

that's it. that's the whole vibe. three pointers, endless power. ๐Ÿ’…


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so the functionality described on this reference page is aligned with the ISO C standard. and listen โ€” any conflict between the requirements described here and the ISO C standard is unintentional, fr fr. this volume of POSIX.1โ€2017 defers to the ISO C standard, periodt.

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. normally, there are three open streams with constant pointers declared in the <stdio.h> header, and they're associated with the standard open files. iconic behaviour honestly.

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) ๐Ÿšจ

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. so like, if it's a terminal, no full buffering for you bestie. ๐Ÿงš

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 is 0. ๐Ÿ“
  • STDOUT_FILENO โ€” standard output value, stdout. its value is 1. โญ
  • STDERR_FILENO โ€” standard error value, stderr. its value is 2. ๐Ÿ’€

zero, one, two. that's the whole file descriptor starter pack. remember it forever, iykyk.

The stderr stream is expected to be open for reading and writing. yes, reading and writing. both. she's versatile. ๐Ÿ’œ


๐ŸŽ€ RETURN VALUE ๐ŸŽ€

None. nothing. not a single thing to return. she gives nothing and that's fine. ๐Ÿ™ˆ


๐ŸŒˆ ERRORS ๐ŸŒˆ

No errors are defined.

also: the following sections are informative. so like, they're the bonus content, not the binding lore. โœจ

๐Ÿ’… EXAMPLES ๐Ÿ’…

None. (i know. we were all hoping.) ๐Ÿ˜ญ


๐Ÿซถ APPLICATION USAGE ๐Ÿซถ

None.


๐Ÿง  RATIONALE ๐Ÿง 

None.


๐Ÿ”ฎ FUTURE DIRECTIONS ๐Ÿ”ฎ

None.


๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

the whole 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>. go read those, bestie, they're lowkey essential. ๐Ÿ“š


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 .


and that's the whole page, bestie!! ๐Ÿ’–โœจ๐ŸŽ€๐Ÿฆ‹๐ŸŒธ

this little love letter to file descriptors came to you courtesy of IEEE/The Open Group, dated 2017, and it lives under the name STDIN(3P). go forth and printf() responsibly. periodt. ๐Ÿ’…๐Ÿ‘‘๐ŸŒˆ

๐Ÿ“ฆ where this page comes from