Chapter 8. CHARACTER INPUTOUTPUT AND REDIRECTION

I l @ ve RuBoard

Chapter 8. CHARACTER INPUT/OUTPUT AND REDIRECTION

In this chapter, you learn more about input, output, and the differences between buffered and unbuffered input. You learn how to simulate the end-of-file condition from the keyboard and how to use redirection to connect your programs to files. Finally, you gain some experience in making the user interface friendlier.

In the computing world, we use the words input and output in several ways. We speak of input and output devices, such as keyboards, disk drives , and laser printers. We talk about the data used for input and output. We discuss the functions that perform input and output. This chapter concentrates on the functions used for input and output ( I/O , for short).

I/O functions transport information to and from your program; printf() , scanf() , getchar () , and putchar () are examples. You've seen these functions in previous chapters, and now you'll be able to look at their conceptual basis. Along the way, you'll see how to improve the program-user interface.

Originally, input/output functions were not part of the definition of C. Their development was left to C's implementors. In practice, the UNIX implementation of C has served as a model for these functions. The ANSI C library, recognizing past practice, contains a large number of these UNIX I/O functions, including the ones we've used. Because such standard functions must work in a wide variety of computer environments, they seldom take advantage of features peculiar to a particular system. Therefore, many C vendors supply additional I/O functions that do make use of special features, such as the 8086 microprocessor I/O ports or the Macintosh ROM routines. These specialized functions enable you to write programs that use a particular computer more effectively. Unfortunately, they often can't be used on other computer systems. Consequently, we'll concentrate on the standard I/O functions available on all systems, for they enable you to write portable programs that can be moved easily from one system to another.

I l @ ve RuBoard


C++ Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 314
Authors: Stephen Prata

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net