Predefined Streams In C

When a C program begins execution, the data streams(pointers to FILE structuers), shown in table will be automatically opened

img

The output of a function like printf goes to the stream stdout. A function like a scanf receives its input from the stream stdin. We can write to any of the outout streams by using functions like fputc, fputs, etc., and read from any of the input streams by using functions like fgetc, fgets, etc. These streams are considered to be files. Usually,, stdout and stderr are connected to the screen, stdin is connected to the parallel port 1ptl.

Thus, the following statements

int i;
scanf (“%d”, &i);
fprint f(stdprn, “%d/n”, i);

will send the output to the printer is online, the number entered will appear on the paper. Note the use of stdprn, instead of the pointer to the FILE structure which is obtained through fopen. Since stdprn is already opened at the beginning of program execution, there is no need to open it again.




About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc





 PreviousNext