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