CS 485 C-Notes

Bob Bradley

The University of Tennessee at Martin

Spring 2002

 

Example of using man to find out about a c function:

 

mars:$ man -k printf

printf printf (1) - write formatted output

printf printf (3c) - print formatted output

printf printf (3ucb) - formatted output conversion

sprintf printf (3c) - print formatted output

...

 

mars:$ man -s 3c printf

 

Standard C Library Functions printf(3C)

 

NAME

printf, fprintf, sprintf, snprintf - print formatted output

 

SYNOPSIS

#include <stdio.h>

 

int printf(const char *format, /* args*/ ...);

int fprintf(FILE *stream, const char *format, /* args*/

...);

int sprintf(char *s, const char *format, /* args*/ ...);

int snprintf(char *s, size_t n, const char *format, /*

args*/ ...);

 

DESCRIPTION

The printf() function places output on the standard output

stream stdout.

 

The fprintf() function places output on on the named output

stream stream.

 

The sprintf() function places output, followed by the null

byte (\0), in consecutive bytes starting at s; it is the

user's responsibility to ensure that enough storage is

available.

 

The snprintf() function is identical to sprintf() with the

addition of the argument n, which specifies the size of the

buffer referred to by s. The buffer is always terminated

with the null byte.

 

RETURN VALUES, ERRORS, USAGE, EXAMPLES, SEE ALSO

 

 

Functions to look up for this class:

 

printf, sprintf, strtok, strcpy, strcat, fflush, gets

 

fork, waitpid, execve

 

open, close, stat, time

 

Strings:

Buffer char command[255];

Pointer char *line;

Null termination