20.09.2015 Views

Programming in C

Kochan - ProgramminginC

Kochan - ProgramminginC

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.

16<br />

Input and Output<br />

Operations <strong>in</strong> C<br />

ALL READING AND WRITING OF DATA up to this po<strong>in</strong>t has been done through your<br />

term<strong>in</strong>al. 1 When you wanted to <strong>in</strong>put some <strong>in</strong>formation, you either used the scanf or<br />

getchar functions. All program results were displayed <strong>in</strong> your w<strong>in</strong>dow with a call to the<br />

pr<strong>in</strong>tf function.<br />

The C language itself does not have any special statements for perform<strong>in</strong>g <strong>in</strong>put/output<br />

(I/O) operations; all I/O operations <strong>in</strong> C must be carried out through function calls.<br />

These functions are conta<strong>in</strong>ed <strong>in</strong> the standard C library.<br />

Recall the use of the follow<strong>in</strong>g <strong>in</strong>clude statement from previous programs that used<br />

the pr<strong>in</strong>tf function:<br />

#<strong>in</strong>clude <br />

This <strong>in</strong>clude file conta<strong>in</strong>s function declarations and macro def<strong>in</strong>itions associated with the<br />

I/O rout<strong>in</strong>es from the standard library.Therefore, whenever us<strong>in</strong>g a function from this<br />

library, you should <strong>in</strong>clude this file <strong>in</strong> your program.<br />

In this chapter, you learn about many of the I/O functions that are provided <strong>in</strong> the<br />

standard library. Unfortunately, space does not permit lengthy details about these functions<br />

or discussions of each function that is offered. Refer to Appendix B,“The Standard<br />

C Library,” for a list of most of the functions <strong>in</strong> the library.<br />

1. Aga<strong>in</strong>, the term “term<strong>in</strong>al” is used loosely here to typically mean the active w<strong>in</strong>dow <strong>in</strong> which<br />

you are runn<strong>in</strong>g your program, or the w<strong>in</strong>dow <strong>in</strong> which the output from your program appears.<br />

On some systems the output w<strong>in</strong>dow is called the “console.”

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

Saved successfully!

Ooh no, something went wrong!