getc(3)
โจ getc โ bestie, let's grab a character from a stream ๐
okay so real talk, we're looking at getc from libc (that's the Standard C library, -lc when you're linking, iykyk).
๐ธ SYNOPSIS ๐ธ
#include <stdio.h>
int getc(FILE *stream);
one function, one FILE *stream pointer, that's the whole vibe ๐
๐ฆ DESCRIPTION ๐ฆ
so getc() is literally the same as fgetc(3)... except for the BUGS (scroll down, bestie, they're juicy ๐ญ).
and honestly? use fgetc(3) instead. that's it, that's the recommendation. periodt.
๐ STANDARDS ๐
this one's repping C23 and POSIX.1-2024. iconic behavior honestly โจ
๐ HISTORY ๐
she's been here a minute: POSIX.1-2001 and C89. a true veteran ๐
๐ BUGS ๐
okay so this is the part where we get messy. two things, bestie:
๐ Multiple evaluation
getc may be implemented as a macro, and it may evaluate stream more than once. so if you're passing something with side effects in there... don't. no cap. ๐ญ
๐ Name
the name is inconsistent. fr fr. people keep confusing it with getchar(3), because normally the <stdio.h> functions that don't have the "f" prefix in their name are the variants that use stdin. so your brain goes "no f = stdin" and then getc is like... no actually ๐ญ the way that naming choice is a crime.
๐ SEE ALSO ๐
fgetc(3)โ the one you should actually be using, she ate ๐
that's the whole page, bestie ๐ซถ go forth and read characters responsibly. this lil writeup came to you from Linux man-pages 6.20, dated 2025-10-10 โ mwah ๐โญ
๐ฆ where this page comes from
- 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 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms