In C, puts(string);
will print string
to stdout, followed by a newline. fputs(fileptr, string);
, on the other hand, will write string
to fileptr
without the trailing newline. Is there any function like fputs()
that appends a newline, or should I stick with fprintf(fileptr, "%s\n", string);
like I've been using?
fputs()
seems more efficient than fprintf()
to me as it doesn't parse it's input. I know I could also use
fputs(string, fileptr);
fputc('\n', fileptr);
but I was wondering if there was a way to do that with one disk write.
I tried to figure out how puts()
appends the newline (since printf()
is really just a wrapper for vfprintf(stdout, ...)
, I thought the same might hold true for puts()
and fputs()
), but I oddly cannot find puts()
in the glibc source.