C runtime returns a pointer from this array. Now, at the application start up time, C Runtime creates/opens three file pointers named stdin, stdout and stderr. They are the first three points of the array elements. The definition is given below:
Stdin is the FILE pointer to access console input which is, by default, the keyboard in PC. Stdout and stderr are the FILE pointer to access console output which is, by default, VGA/SVGA console in PC. Stdout is used for normal output printing whereas stderr is used for error outputs.
C runtime never accesses the keyboard or display consoles directly. Instead it sends the string buffer to the file and from the device driver output goes to the corresponding devices.
This mechanism is very useful when dealing with different types of input and output devices. In embedded systems, serial ports are often used as input and output devices. Printf/Scanf never opens the file directly. We have to set the default console to serial port from kernel or using set console handle option. Stdin, Stdout and stderr will be changed accordingly.
You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.