PUTC(3POSIX)
π PUTC(3POSIX) β the POSIX Programmer's Manual, bestie edition π
okay so welcome to the POSIX Programmer's Manual entry for putc, aka the girl who puts a byte on a stream and doesn't make a big deal about it π
π¨ PROLOG (read this first, fr fr)
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
no cap, that's a real disclaimer. Linux might do its own lil thing. check the Linux page. or maybe it just doesn't exist on Linux at all?? vibe check your platform first π«Ά
β¨ NAME β¨
putc β put a byte on a stream
that's it. that's the whole job. iconic, honestly π
πΈ SYNOPSIS πΈ
#include <stdio.h>
int putc(int c, FILE *stream);
like. look at her. two args, returns an int. simple. elegant. slay β¨
π DESCRIPTION π
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.
so basically: ISO C is the main character here, POSIX is just β¨supportingβ¨. if they ever disagree it's an accident, and ISO C wins. periodt.
The putc() function shall be equivalent to fputc(), except that if it is implemented as a macro it may evaluate stream more than once, so the argument should never be an expression with side-effects.
okay this is the important part, don't skip it π β putc() does the exact same thing as fputc(). BUT. she might be a macro, and if she is, she can evaluate stream more than once. so bestie, please, do not hand her an expression with side-effects. she will read it twice and chaos will ensue. π
π₯ RETURN VALUE π₯
Refer to fputc().
not me redirecting you... but fr fr, the return value tea is all in fputc(). go look. i'll wait. π
π ERRORS π
Refer to fputc().
same deal, the error lore lives in fputc(). nothing new here, she's just borrowing her sister's notes.
The following sections are informative.
(translation: the rest of this page is β¨vibes and contextβ¨, not hard requirements. informative, not normative. iykyk)
π EXAMPLES π
None.
literally none. the well is dry. no examples today, bestie π we're all just rawdogging the spec.
π APPLICATION USAGE π
Since it may be implemented as a macro, putc() may treat a stream argument with side-effects incorrectly. In particular, putc(c,*f++) does not necessarily work correctly. Therefore, use of this function is not recommended in such situations; fputc() should be used instead.
so here's the tea β β because putc() might be a macro, a stream argument with side-effects can get handled incorrectly. the classic example:
putc(c,*f++)
does not necessarily work correctly. like. it might. it might not. it's giving undefined-ish behavior and we don't do that here. π ββοΈ
so in these situations? use of this function is not recommended. use fputc() instead. she's the safe, well-behaved sister. π«Ά
π§ RATIONALE π§
None.
no rationale. she simply is. main character energy, no explanation needed. π
π¦ FUTURE DIRECTIONS π¦
None.
nothing planned. she's staying exactly as she is. stable queen. π
β SEE ALSO β
- Section 2.5, Standard I/O Streams
fputc()
and also: The Base Definitions volume of POSIX.1β2017, <stdio.h>
go read those if you want the full lore drop πβ¨
π COPYRIGHT π
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 one came to you from IEEE/The Open Group, 2017, which is the source and date you'll see at the bottom of the original β so consider that my lil sign-off. mwah π go forth and fputc() responsibly β¨π¦π
π¦ 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