On this page
fputs
Prev: fgets | Up: stdio.h | Next: fopen
Rel: stdio.h, stdio.h & File I/O Guide
Ref: cppreference — fputs
Tags: #public #prog #c #stdlib #stdio #tier/standard
Include
#include <stdio.h>
Signature & Overview
int fputs(const char *restrict str, FILE *restrict stream);
Writes a NUL-terminated string to stream without appending a newline (unlike puts).
Notes & Pitfalls
- Does NOT append a newline (unlike
puts()), and does not interpret%format specifiers—safer and faster thanfprintf(f, "%s", s).
Example
#include <assert.h>
#include <stdio.h>
int main(void) {
FILE *f = tmpfile();
assert(fputs("raw line\n", f) != EOF);
fclose(f);
}
Linked from
Related notes
- tuts/c/stdlib/stdio/fgets Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fopen Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib
- tuts/c/stdlib/stdio_and_file_io Linked here; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/stdio/fclose shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/feof shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/ferror shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fflush shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fprintf shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fread shared tags: #c, #prog, #stdio, #stdlib, #tier