Reputation: 21
I'm programming with gcc
in CentOS 5.5 and the most of time I use printf()
and fprintf()
to print on terminal, but in some websites I've seen that some people use write()
. I want to know if there's other ways to print on terminal.
Thanks.
Upvotes: 0
Views: 4132
Reputation: 753675
All the output functions in the C standard I/O library could be used:
fprintf()
fputc()
fputs()
fputwc()
fputws()
fwprintf()
fwrite()
printf()
putc()
putchar()
puts()
putwc()
putwchar()
vfprintf()
vfwprintf()
vprintf()
vwprintf()
wprintf()
Most of the other write-like functions in POSIX could be used (but a few are reserved for sockets and those probably can't be used).
There are many functions in the curses
library that could be used.
Upvotes: 1
Reputation: 122383
There are some major differences between these functions.
stdout
: printf
, puts
, putchar
etc.stdout
: fprintf
, fputs
, fwrite
, etc.write
is different, it's a low-level I/O function. The
standard library doesn't provide any low-level I/O functions. For
example, POSIX provides write
that can output to a file
descriptor.Google for how to use each one of them.
Upvotes: 2
Reputation: 7324
You could use puts()
or putchar()
.
puts("Hello, world!\n");
There's a also fputs()
, putc()
, and fputc()
if you want/need to specify a FILE*
to write to.
Upvotes: 1