NAME |LIBRARY |SYNOPSIS |DESCRIPTION |RETURN VALUE |ATTRIBUTES |STANDARDS |HISTORY |BUGS |SEE ALSO |COLOPHON | |
puts(3) Library Functions Manualputs(3)fputc, fputs, putc, putchar, puts - output of characters and strings
Standard C library (libc,-lc)
#include <stdio.h>int fputc(intc, FILE *stream);int putc(intc, FILE *stream);int putchar(intc);int fputs(const char *restricts, FILE *restrictstream);int puts(const char *s);
fputc() writes the characterc, cast to anunsigned char, tostream.putc() is equivalent tofputc() except that it may be implemented as a macro which evaluatesstream more than once.putchar(c) is equivalent toputc(c, stdout).fputs() writes the strings tostream, without its terminating null byte ('\0').puts() writes the strings and a trailing newline tostdout. Calls to the functions described here can be mixed with each other and with calls to other output functions from thestdio library for the same output stream. For nonlocking counterparts, seeunlocked_stdio(3).fputc(),putc(), andputchar() return the character written as anunsigned char cast to anint orEOFon error.puts() andfputs() return a nonnegative number on success, orEOF on error.
For an explanation of the terms used in this section, seeattributes(7). ┌──────────────────────────────────────┬───────────────┬─────────┐ │Interface│Attribute│Value│ ├──────────────────────────────────────┼───────────────┼─────────┤ │fputc(),fputs(),putc(),putchar(), │ Thread safety │ MT-Safe │ │puts() │ │ │ └──────────────────────────────────────┴───────────────┴─────────┘
C11, POSIX.1-2008.
POSIX.1-2001, C89, C99.
It is not advisable to mix calls to output functions from thestdio library with low-level calls towrite(2) for the file descriptor associated with the same output stream; the results will be undefined and very probably not what you want.
write(2),ferror(3),fgets(3),fopen(3),fputwc(3),fputws(3),fseek(3),fwrite(3),putwchar(3),scanf(3),unlocked_stdio(3)
This page is part of theman-pages (Linux kernel and C library user-space interface documentation) project. Information about the project can be found at ⟨https://www.kernel.org/doc/man-pages/⟩. If you have a bug report for this manual page, see ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩. This page was obtained from the tarball man-pages-6.15.tar.gz fetched from ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on 2025-08-11. If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up- to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which isnot part of the original manual page), send a mail to man-pages@man7.orgLinux man-pages 6.15 2025-05-17puts(3)Pages that refer to this page:curs_addch(3x), curs_termcap(3x), curs_terminfo(3x), fgetc(3), flockfile(3), fputwc(3), fputws(3), gets(3), getw(3), printf(3), putwchar(3), setbuf(3), stdio(3)
HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface. For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere. Hosting byjambit GmbH. | ![]() |