Programming in C

(Barry) #1

16 Input and Output Operations in C


16 Input and Output Operations in C


ALL READING AND WRITING OF DATAup to this point has been done through your
terminal.^1 When you wanted to input some information, you either used the scanfor
getcharfunctions. All program results were displayed in your window with a call to the
printffunction.
The C language itself does not have any special statements for performing input/out-
put (I/O) operations; all I/O operations in C must be carried out through function calls.
These functions are contained in the standard C library.
Recall the use of the following includestatement from previous programs that used
the printffunction:


#include <stdio.h>


This include file contains function declarations and macro definitions associated with the
I/O routines from the standard library.Therefore, whenever using a function from this
library, you should include this file in your program.
In this chapter, you learn about many of the I/O functions that are provided in the
standard library. Unfortunately, space does not permit lengthy details about these func-
tions or discussions of each function that is offered. Refer to Appendix B, “The Standard
C Library,” for a list of most of the functions in the library.



  1. Again, the term “terminal” is used loosely here to typically mean the active window in which
    you are running your program, or the window in which the output from your program appears.
    On some systems the output window is called the “console.”

Free download pdf