GETC(3P)
π GETC(3P) β get a byte from a stream π
okay bestie, pull up a chair, we're doing the POSIX Programmer's Manual today β specifically the page for getc, from the POSIX Programmer's Manual. β¨
πΈ PROLOG πΈ
Real talk first, no cap: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β so if that's your situation, go consult the corresponding Linux manual page for the details of Linux behavior. Or, plot twist, the interface may not be implemented on Linux at all. π So likeβ¦ check before you commit, okay?
π NAME π
getc β grab a byte from a stream. that's it. that's the whole job. π
β¨ SYNOPSIS β¨
#include <stdio.h>
int getc(FILE *stream);
she's small, she's tidy, she returns an int π
π¦ DESCRIPTION π¦
So the vibe here: the functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of POSIX.1β2017 defers to the ISO C standard. π«Ά
And now the actual tea β β the getc() function shall be equivalent to fgetc(), except that if it's implemented as a macro, it may evaluate stream more than once. Which means the argument should never be an expression with side-effects. π¨ fr fr, do not do that.
π RETURN VALUE π
Not her turn to explain: Refer to fgetc(). π«‘
π ERRORS π
Refer to fgetc(). Same energy, same page, go read hers.
And also, heads up: the following sections are informative. (i.e. the vibes sections, not the rules sections β¨)
π EXAMPLES π
None. π not a single one. iconic of her honestly.
π APPLICATION USAGE π
okay so this is the part where I hold your hand, bestie:
- If the integer value returned by
getc()is stored into a variable of typecharand then compared against the integer constantEOF, the comparison may never succeed β because sign-extension of a variable of typecharon widening to integer is implementation-defined. π so like. store it in anint. please. - Since it may be implemented as a macro,
getc()may treat incorrectly astreamargument with side-effects. In particular,getc(*f++)does not necessarily work as expected. Therefore, use of this function should be preceded by#undefgetcin such situations;fgetc()could also be used. π§
Two escape hatches, pick your fave: #undefgetc or just call fgetc(). π«Ά
π RATIONALE π
None. she said no thoughts, head empty. respect. π
β FUTURE DIRECTIONS β
None. no drama on the horizon. we love a stable queen. π
π₯ SEE ALSO π₯
- Section 2.5, Standard I/O Streams,
fgetc() - The Base Definitions volume of POSIX.1β2017,
<stdio.h>
iykyk β go read fgetc(), she's the main character, getc is literally her macro-flavored twin. πΈ
π§ COPYRIGHT π§
okay legal moment, stay with me, this matters:
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 edition dropped in 2017, courtesy of IEEE/The Open Group, and it's the GETC(3P) page β go forth and read your bytes responsibly, mwah π
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms