C programming language - ch7 - Input and Output


Table of Contents

1 7.1 Standard input and output

#include <stdio.h>

int getchar(void)

returns the next input character each time it is called, or EOF when it encounters end of file. Then symbolic constant EOF is defined in <stdio.h>

int putchar(int)

puts the character c on the standard output. Returns the character written, or EOF is an error occurs.

Calls to putchar and printf may be interleaved.


A width or precision may be specified as *, in which case the value is computed by converting the next argument (which must be an int). Foe example, to print at moast max characters from a string s :

printf("%.*s", max, s);

The function sprintf does the same conversions as printf does, but stores the output in a string

int sprintf(char *string, char *format, arg1, arg2, …);

2 7.3 Variable-length Argument Lists

Author: Sebastian Emilio Narvaez

Created: 2019-10-12 Sat 22:16

Emacs 25.2.2 (Org mode 8.2.10)