Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Preview
Input and output facilities are not part of
the C language itself
ANSI defines a standard library, including
functions to do
Input and output
String handling
Storage management
Mathematical routines
…
Where is the headers of
standard library?
In Unix system, it is in /usr/include
Standard headers (.h file)
Function declarations
Types declarations
Macros declarations
<assert.h> <float.h> <math.h> <stdarg.h> <stdlib.h>
<ctype.h> <limit.h> <setjmp.h> <stddef.h> <string.h>
<errno.h> <locale.h><signal.h> <stdio.h> <time.h>
Character input and output
I/O devices are taken as files
stdin stdout
program
Input/output redirection
a.out < infile
a.out > outfile
a.out < infile > outfile
a.out < infile | prog2 ch7e1.c
Formatted output - printf
Prototype
int printf(char *format, arg1, arg2, …)
Data type
“…..%-7.5f….”
ch7e3.c
Formatted output - scanf
prototype
int scanf(char *format, arg1, arg2, …)
No. of matched
items The same as
printf
pointer: provide address
of the variable
ch7e4.c : calculator
Formatted output - scanf
White space chars are ignored in scanf
ch7e5.c