24.12.2012 Views

CSC322 C Programming and UNIX - Department of Computer ...

CSC322 C Programming and UNIX - Department of Computer ...

CSC322 C Programming and UNIX - Department of Computer ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The printf() Family <strong>of</strong> Functions<br />

All functions are declared in <br />

int printf(char *format, ...);<br />

– Print the additional arguments under control <strong>of</strong> the argument string to stdout<br />

– Returns number <strong>of</strong> characters printed, or any negative number on error<br />

int fprintf(FILE *stream, char *format, ...);<br />

– As printf(), but print to the designated output stream<br />

int sprintf(char *s, char *format, ...);<br />

– Instead <strong>of</strong> actually printing anything, sprintf() will store the output characters<br />

in the character array s points to<br />

– The string will be \0 terminated<br />

– It is the responsibility <strong>of</strong> the programmer to make sure *s is big enough<br />

– The returned count <strong>of</strong> characters does not include the terminating nul character<br />

(i.e. it is the same value that printf() would return)<br />

Stephan Schulz 416

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!