CPlusOne
Notes, Syllabus, Questions, Ideas,
Books, Reference materials on Electronics


Quick Links
#Login #Sign up #Forum #Feedback

 

#Previous question #Index of C Questions #Next question

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[0])
#define stdout (&_iob[1])
#define stderr (&_iob[2])
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.

 Vote 0

Similar topics related to this section

structured programming language, first C program, header files, library, compilation, pre-processing, compilation, optimization, linking format, debugging with GDB, data types, storage classes, if, if-else, if-else-if, label and goto, switch case, loop statements, break and continue, pointers, enum type, macro, basic operators, logical operators, logical vs bitwise operators, bit shifting, bit set, reset/clear, toggle, Operator precedence, array, multidimensional arrays, user defined types, typedef, struct type, union type, struct vs union, struct pack padding, bit fields, structure as function argument, array as function argument, printing pointers, scanf string input, scan string with blanks, scanf string ends with newline, return of scanf, return of printf, scanf with printf, print using fprintf, take input using fscanf, floating point formatting, multiple arguments in printf and scanf, variadic functions, variadic macro, calling conventions, calling convention of C,C++ and PASCAL, operator precedence, ternary operator, switch statement, continue in switch and loops, for, while, do-while loop syntax, for to while, do-while and while usage, infinite loops, function declaration and definition, library function linking, call-by-value and call-by-reference, parameter passing call-by-value, parameter passing call-by-reference, address of local and dynamic variable, volatile variable, external vs static, global vs static variable, register vs auto variable, const, macro vs constant, debug builds, debug macros, compiler macro for C++, FILE, LINE, DATE, TIME, compiler marcos, token pasting, characterizing, const char *,char * const, const char * const, char array and char pointers, enum vs macro, write vs append mode, binary vs text mode, macro vs typedef, size of a structure, upper and lower 16bit of 32bit unsigned, near, far and huge pointer, typed pointers and void pointer, sizeof void, sizeof void and void pointer, operators for void pointer, l-value, struct and array, NULL pointer, inline-functions, macro vs inline-function, malloc vs calloc, function pointer, compare with ==, argc and argv, C startup routine, strcpy and strcat source, signed and unsigned compare, string vs integer pointer, xor operator, bitwise shifting, logical and bitwise or, macro definition, long pointer increment, default C++ argument value, short pointer increment, execution sequence, exceptions, setjump and longjump, trace a memory leak, detect memory corruption, C and Data Structures, Data Structures using array, Linked List, Single Linked list, Doubly Linked list, Circular Linked list, Doubly Circular Linked list, Tree and Binary tree, heap, Complexity, Linear Search, Binary Search, Hash Table, Sorting, Bubble Sort, Selection Sort, Insertion Sort, Quick Sort, Heap Sort, Merge sort, Radix Sort, Recursion, argv environ, system(),

# C/C++ Interview questions and answers - Shetty's World
# C Interview Questions and Answers - C Interview FAQs & C Books
# C interview questions and answers | TechInterviews
# C Interview Questions and Answers :: ALL Interview .com
# C Interview Questions and Answers

* #1 webmaster Sun 02 Feb/2014 21:24:39(GMT)  Like 0 Unlike 0

Dear Users,

We are pleased to inform you that a forum/blog has been incorporated with www.mybestnotes.co.in. You are welcomed to add your comments, requests, codes, solutions and feedback to it. Please login(if already a member) or signup(for free) to avail to this facility.

Regards,
Webmaster

Your message goes here:

Name:Guest
Email:anonymous@unknown.com
My Post:*
Secutiry Code: ******  *
Preview this compose before posting this in discussion forum.
 
Note:
  1. Use [Sxx] code to show smiles. Example [S02]
  2. Use [URL ], example [URL http://www.google.com/]
  3. To display code or un formatted text use [CODE] [/CODE]. Example: [CODE] printf("Hello world"); [/CODE]
 [S01]   [S02]   [S03]   [S04]   [S05]   [S06]   [S07]   [S08] 
 [S09]   [S10]   [S11]   [S12]   [S13]   [S14]   [S15]   [S16] 
 [S17]   [S18]   [S19]   [S20]   [S21]   [S22]   [S23]   [S24] 

Note: Only members are allowed, * fields are mandatory.