I/O Functions

Input and output devices play a key role indata processing. the first phase of processing data is input. Data is accepted in the form of input and output is generated after processing data. C++ language does not facilitate input and output with the help of keywords. Input and output operations are performed with the help of library functions. There are header files which help in performing input/output activities.

Header Files in C++

The list of keywords in C++ does not include functions. However, built in functions are available with C++ library header files. Declarations of function prototypes, classes etc. are provided by header files. The function prototypes are pre-declared before using them in the program.

A function prototype is the declaration of a function specifying a function's name, number and type of arguments (data values) and the type of value returned by the function.

A header file can be included in a C++ program using a pre-processor directive # include. A preprocessor directive is an instruction for the compiler to be executed before the compilation of the program code actually takes place. This is known as pre-processing stage.

# include directive.

The #include directive tells the preprocessor to treat the contents of a specified file as if those contents had appeared in the source program at the point where the directive appears. You can organize constant and macro definitions into include files and then use #include directives to add these definitions to any source file. Include files are also useful for incorporating declarations of external variables and complex data types. You need to define and name the types only once in an include file created for that purpose.

There are two ways of including header files:

#includestdio.h> // from standard include directory

#include"myfile.h" // from current directory

When a heaser file name is enclosed within angle brackets < and >, this means that the file is available in the directory where the standard header files are stored.

When a header file name is enclosed within double quotes, this means that the file is available in the curent directory. This method is generally used when header files are created by the user and are avialable in the user's current directory.

Standard Devices in C++

When the header file stdio.h is included in a program, the following standard stream pointers are automatically opened.