why?
Printable View
why?
To put a line to a file stream. Duh!
Quzah.
To print a line of text to the screen, you might want to use it instead of puts() because it doesn't append a newline.
puts() appends a newline.
That was my point.
Thanks for the answers but to make the questions more clear.Why not use the conventional printf.BTW Quzah i dont understand what you said
Because printf always goes to stdout, but fputs can go to any file, of course.
Now a better question might be "why use fputs instead of fprintf?" and the answer to that is, it's simpler, and therefore somewhat quicker and somewhat smaller (which is a win if you're statically linking your libc).
fputs() doesn't have to parse the string "%s" to figure out that all you want to do is print a string.
In other words, you have to prepare your string ahead of time for fputs, where fprintf allows you to format at the time of outputting.
Quzah.
If you're just trying spit out a simple message that doesn't need formatting like "You win!" then puts()/fputs() is more efficient.