212 Programming and Data Structures
char msgl] = "C is Easy";
inti = 0;
clrscrO;
while (msglU)
putc(msg[i++], stdout);
I
Q U m K i
C is Easy
Explanation A character array and integer variable are initialized. Array always begins with element
number 0. In case % i ' is not initialized with 0 result provides garbage value. Standard stdo u t ()
function prints the string on console. Here the string is "C i s Easy".
7.6 PREDEFINED STREAMS
Following are the streams
1. stdin()
2. stdout ()
3. stderrO
When C program is executed few "files" are automatically opened by the system for use by the
program. Constant FILE pointers recognize these files. Streams s td in , s tdou t and s t der r are
defined in the standard I/O include files. These are macros. Their details are illustrated in the chapter
12] PREPROCESSOR DIRECTIVES.
a) stdin The file pointer s tdin identifies the standard input text and it is associated with our terminal.
All standard I/O functions perform input and do not take a FILE pointer as an argument and get their
input from s tdin.
b) stdout Similarly, it is used for outputting the text. It is a standard output stream.
c) a tderr It is an output stream in the text mode. It is a standard error stream.
7.18 Write a program to read the text through keyboard and display it by using stdin and
stdout Streams.
#include <stdio.h>
main (void)
{
char ch[ll] ;
int i;
clrscrO;
printf("lnput aText:");
for (i=0;i<10;i++)
chli]=getc(stdin);
printf("The Text inputted was");
for (i=0,i<10;i++)