Information About

Stdio.h




stdio.h, which stands for "standard input-output header," is the library in C Programming Language which contain functions for manipulating standard Input and Output . It contains Macro definitions, constants, and declarations of functions and types used for various input and output operations. It is compatible with C++ and is more widely known as the cstdio library in C++.

stdio.h is extremely popular, since as a part of the C Standard Library it is guaranteed to work on any platform which supports C. Applications on a particular platform might, however, have reasons to use the platform's I/O routines, rather than the stdio.h routines.


EXAMPLE USAGE

All functions in C and its derivatives are included from Header File s. Similarly, Programmer s have to include the stdio.h header into the source code to utilize the functions. This is the origin where the library name came from.

#include

int main() {
while (!feof(stdin)) putchar(getchar());
return 0;
}

The above Program reads all input from the console and echo it onto the console, line by line.


MEMBERS

Member functions of the stdio.h library can generally be divided into two categories: the functions for file manipulation and the functions for input-output manipulation.


File manipulation functions











Input-output manipulation functions















Member constants

Member constants of the stdio.h library include:
  • EOF - a negative integer of type int used to indicate end-of-file conditions.

  • Stdin

  • Stdout

  • stderr - stores errors occurred on the standard streams.

  • BUFSIZ - an integer which is the size of the buffer used by the setbuf() function.

  • FILENAME_MAX - the size of a char array which is large enough to store the name of any file that can be opened.

  • FOPEN_MAX - the number of files that may be open simultaneously.

  • --- at least 8

  • _IOFBF - an abbreviation for "input/output fully buffered"; it is an integer which may be passed to the setvbuf() function to request ''block buffered'' input and output for an open stream.

  • _IOLBF - an abbreviation for "input/output line buffered"; it is an integer which may be passed to the setvbuf() function to request ''line buffered'' input and output for an open stream.

  • _IONBF - an abbreviation for "input/output not buffered"; it is an integer which may be passed to the setvbuf() function to request ''unbuffered'' input and output for an open stream.

  • L_tmpnam - the size of a char array which is large enough to store a temporary filename generated by the tmpnam() function.

  • NULL - a Null Pointer constant; that is, a value which will never be equivalent to a pointer to a valid location in memory.

  • SEEK_CUR - an integer which may be passed to the fseek() function to request positioning relative to the current file position.

  • SEEK_END - an integer which may be passed to the fseek() function to request positioning relative to the end of the file.

  • SEEK_SET - an integer which may be passed to the fseek() function to request positioning relative to the beginning of the file.

  • TMP_MAX - the maximum number of unique filenames generable by the tmpnam() function.



Types

  • FILE - a structure containing the information about a file or text stream needed to perform input or output operations on it, including:

  • --- the current stream position

  • --- an end-of-file indicator

  • --- an error indicator

  • --- a pointer to the stream's buffer, if applicable

  • fpos_t - a non-array type capable of uniquely identifying the position of every byte in a file.

  • size_t - an unsigned Integer type which is the type of the result of the Sizeof operator.