Syntax: fprintf(stdout, <string format>, <arguments>); Example: fprintf(stdout, "Print using fprintf");C Runtime maintains an array of FILE structures named _iob (VC++ compiler) for accessing file system APIs. For example: if we want to open a file:
FILE * fp = NULL; fp = fopen(<file path>, <mode>);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:
#define stdin (&_iob) #define stdout (&_iob) #define stderr (&_iob)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.
About our authors: Team EQA
You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Draw on printer Free alt softwares