Data Input and Output functions in C


Data Input and Output functions in C

Input /Output functions are used to accept values in to variables and printing them after the processing is over.
The input and output of data can be done through the standard input /output media or through files.
The standard input medium is the keyboard , whereas the standard output medium is the console.

I/O operation in C

The C is accompanied by a collection of header files that provides necessary information. Each header files contains information in support of a group of related library functions. These files are included in the program by giving the #include statement at the beginning of the program.
The header file required by the standard input /output library functions is called stdio.h
An input /output function can be accessed from anywhere within the program by writing the function name, followed by list of arguments enclosed with in parenthesis.
The argument represents the data items that are sent to the function.
Some input /output functions return data items where as other doesn’t .

The functions returning data items may appear within expressions, as though each function reference were an ordinary variable.
For example:
C=getchar();

On the other hand functions not returning data items may be referenced as though they were separate statements,
For example:
        putchar(…);

The C library contains two distinct system of routines that handle input/output  operations.
·       Buffered I/O
·       Unbuffered I/O

A buffered I/O is used to read and write ASCII characters whereas an Unbuffered I/O is used to read and write binary data.

A buffer is a temporary storage area , either in memory or on the controller card for the device.

In buffered I/O ,the character typed at the keyboard are collected until the user presses the Return or Enter key. the characters are made available to the program as a block.

Buffered I/O can be further classified in to
·       Console I/O
·       Buffered file I/O

Console I/O refers to the operation at occurs at the keyboard and the screen of your computer.

Buffered file I/O refers to the operations that are performed to read and write data on to a file.

In unbufferd I/O , the character that the user enters at the keyboard is made available to the program immediately with out being temporaily stored in a buffer location.it is not necessary to press the Enter key to register the character.

A buffered system is preferred over an unbuffered system for the following reasons:
  • ·       I/O operation on a buffered system is less time consuming.
  • ·       In the event when mistakes are made and the enter key is not pressed, the mistakes can be corrected.

In some cases unbuffered I/O is desired in interactive programs . A word processing program is an example.

Thank  you …

 Link to my home page  :https://iamafutureprogrammer.blogspot.com/

Previous Post
Next Post
Related Posts

0 comments:

Popular Posts