Predefined streams

Predefined streams :

following are the streams....
  1. stdin( )
  2. stdout( )
  3. stderr( )
When c program is execute few "files"are  automatically opened by the system for use by the program.Constant FILE pointers recognise these files.Streams stdin,stdout,stderr are defined in the standard input and output include files. These are macros.Their details are illustrate in the chapter preprocessor directives.
  1. stdin : The file pointer stdin identifies the standard input text and it is associated with our                     terminal.All standard input and output functions perform input and do not take a FILE               pointer as an argument and get their input from stdin.
  2. stdout : Similarly,it is used for outputting the text .It is a standard output stream.
  3. stderr : It is an output stream in the text mode.  It is a standard error stream.
Example :
#include<stdio.h>
main( ) 
{
char ch[11];
int i;
printf("input a text");
for(i=0;i<10;i++)
ch[i]=getc(stdin);
printf("The text inputted was");
for(i=0;i<10;i++)
putc(ch[i],stdout);
}
OUTPUT:
input a text : Hello world
The text entered was 
Hello world

Explanation :
In the above program two for loops are used.The first for loop reads input character from the keyboard and stores in an array ch [11] by using stdin standard function.The second for loop display the string using stdout standard function.