FPUTC(3POSIX)
π fputc(3POSIX) β put a byte on a stream π
hey bestie π«Ά welcome to the POSIX Programmer's Manual, this one's the fputc(3POSIX) page. it's short, it's sweet, it's giving "tiny function, huge responsibility". let's get into it β¨
πΈ PROLOG πΈ
okay so first thing, important disclaimer energy: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ (so like, go check the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface might not even be implemented on Linux at all. π so don't come for me if Linux does its own thing.
π NAME π
fputc β put a byte on a stream. that's it. that's the whole job. iconic. π
β¨ SYNOPSIS β¨
#include <stdio.h>
int fputc(int c, FILE *stream);
π¦ DESCRIPTION π¦
the functionality on this reference page is aligned with the ISO C standard. if anything here conflicts with the ISO C standard requirements, that conflict is unintentional β no drama intended. this volume of POSIX.1β2017 defers to the ISO C standard, periodt.
so here's what fputc() actually does, bestie:
- it writes the byte specified by
cβ converted to anunsigned charβ to the output stream pointed to bystream. - it writes at the position indicated by the associated file-position indicator for the stream, if that indicator is defined.
- and then it advances that indicator appropriately. β¨
now, if the file cannot support positioning requests, or if the stream was opened in append mode, then the byte just gets appended to the output stream instead. slay.
also, timestamp tea π«: the last data modification and last file status change timestamps of the file shall be marked for update between the successful execution of fputc() and the next successful completion of a call to fflush() or fclose() on the same stream, or a call to exit() or abort(). mark it and move on. π
π₯ RETURN VALUE π₯
upon successful completion, fputc() shall return the value it has written. cute, right?
otherwise? it returns EOF, the error indicator for the stream shall be set, and errno shall be set to indicate the error. so like, it tells you what went wrong. we love accountability. π
π ERRORS π
the fputc() function shall fail if either the stream is unbuffered or the stream's buffer needs to be flushed, and:
EAGAINβ theO_NONBLOCKflag is set for the file descriptor underlying stream, and the thread would be delayed in the write operation. bestie is not in the mood to wait. π€EBADFβ the file descriptor underlying stream is not a valid file descriptor open for writing. wrong fd, no write privileges, tragic.EFBIGβ an attempt was made to write to a file that exceeds the maximum file size.EFBIGβ an attempt was made to write to a file that exceeds the file size limit of the process.EFBIGβ the file is a regular file and an attempt was made to write at or beyond the offset maximum.EINTRβ the write operation was terminated due to the receipt of a signal, and no data was transferred. interrupted mid-sentence, rude.EIOβ a physical I/O error has occurred, or the process is a member of a background process group attempting to write to its controlling terminal,TOSTOPis set, the calling thread is not blockingSIGTTOU, the process is not ignoringSIGTTOU, and the process group of the process is orphaned. this error may also be returned under implementation-defined conditions.ENOSPCβ there was no free space remaining on the device containing the file. the disk said "no β€οΈ".EPIPEβ an attempt is made to write to a pipe or FIFO that is not open for reading by any process. aSIGPIPEsignal shall also be sent to the thread. π¨
the fputc() function may fail if:
ENOMEMβ insufficient storage space is available.ENXIOβ a request was made of a nonexistent device, or the request was outside the capabilities of the device.
heads up: the following sections are informative. π’
π EXAMPLES π
None.
(yeah. nothing. empty. we move. π)
π APPLICATION USAGE π
None.
π§ RATIONALE π§
None.
β FUTURE DIRECTIONS β
None.
π SEE ALSO π
- Section 2.5, Standard I/O Streams
ferror()fopen()getrlimit()putc()puts()setbuf()ulimit()- The Base Definitions volume of
POSIX.1β2017,<stdio.h>
π 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, no cap π«Ά this was IEEE/The Open Group, 2017 doing FPUTC(3POSIX) things β go forth and write your bytes, you absolute icon πβ¨
π¦ 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