- C Library - <time.h>
- C Library - <string.h>
- C Library - <stdlib.h>
- C Library - <stdio.h>
- C Library - <stddef.h>
- C Library - <stdarg.h>
- C Library - <signal.h>
- C Library - <setjmp.h>
- C Library - <math.h>
- C Library - <locale.h>
- C Library - <limits.h>
- C Library - <float.h>
- C Library - <errno.h>
- C Library - <ctype.h>
- C Library - <assert.h>
- C Library - Home
C Standard Library Resources
C Programming Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
C Library - <stdio.h>
The stdio.h header defines three variable types, several macros, and various functions for performing input and output.
Library Variables
Following are the variable types defined in the header stdio.h −
Sr.No. | Variable & Description |
---|---|
1 |
size_t This is the unsigned integral type and is the result of the sizeof keyword. |
2 |
FILE This is an object type suitable for storing information for a file stream. |
3 |
fpos_t This is an object type suitable for storing any position in a file. |
Library Macros
Following are the macros defined in the header stdio.h −
Sr.No. | Macro & Description |
---|---|
1 |
NULL This macro is the value of a null pointer constant. |
2 |
_IOFBF, _IOLBF and _IONBF These are the macros which expand to integral constant expressions with distinct values and suitable for the use as third argument to the setvbuf function. |
3 |
BUFSIZ This macro is an integer, which represents the size of the buffer used by the setbuf function. |
4 |
EOF This macro is a negative integer, which indicates that the end-of-file has been reached. |
5 |
FOPEN_MAX This macro is an integer, which represents the maximum number of files that the system can guarantee to be opened simultaneously. |
6 |
FILENAME_MAX This macro is an integer, which represents the longest length of a char array suitable for holding the longest possible filename. If the implementation imposes no pmit, then this value should be the recommended maximum value. |
7 |
L_tmpnam This macro is an integer, which represents the longest length of a char array suitable for holding the longest possible temporary filename created by the tmpnam function. |
8 |
SEEK_CUR, SEEK_END, and SEEK_SET These macros are used in the fseek function to locate different positions in a file. |
9 |
TMP_MAX This macro is the maximum number of unique filenames that the function tmpnam can generate. |
10 |
stderr, stdin, and stdout These macros are pointers to FILE types which correspond to the standard error, standard input, and standard output streams. |
Library Functions
Following are the functions defined in the header stdio.h −
Sr.No. | Function & Description |
---|---|
1 |
Closes the stream. All buffers are flushed. |
2 |
Clears the end-of-file and error indicators for the given stream. |
3 |
Tests the end-of-file indicator for the given stream. |
4 |
Tests the error indicator for the given stream. |
5 |
Flushes the output buffer of a stream. |
6 |
Gets the current file position of the stream and writes it to pos. |
7 |
Opens the filename pointed to by filename using the given mode. |
8 |
Reads data from the given stream into the array pointed to by ptr. |
9 |
Associates a new filename with the given open stream and same time closing the old file in stream. |
10 |
Sets the file position of the stream to the given offset. The argument offset signifies the number of bytes to seek from the given whence position. |
11 |
Sets the file position of the given stream to the given position. The argument pos is a position given by the function fgetpos. |
12 |
Returns the current file position of the given stream. |
13 |
Writes data from the array pointed to by ptr to the given stream. |
14 |
Deletes the given filename so that it is no longer accessible. |
15 |
Causes the filename referred to, by old_filename to be changed to new_filename. |
16 |
Sets the file position to the beginning of the file of the given stream. |
17 |
Defines how a stream should be buffered. |
18 |
Another function to define how a stream should be buffered. |
19 |
Creates a temporary file in binary update mode (wb+). |
20 |
Generates and returns a vapd temporary filename which does not exist. |
21 |
Sends formatted output to a stream. |
22 |
Sends formatted output to stdout. |
23 |
Sends formatted output to a string. |
24 |
Sends formatted output to a stream using an argument pst. |
25 |
Sends formatted output to stdout using an argument pst. |
26 |
Sends formatted output to a string using an argument pst. |
27 |
Reads formatted input from a stream. |
28 |
Reads formatted input from stdin. |
29 |
Reads formatted input from a string. |
30 |
Gets the next character (an unsigned char) from the specified stream and advances the position indicator for the stream. |
31 |
Reads a pne from the specified stream and stores it into the string pointed to by str. It stops when either (n-1) characters are read, the newpne character is read, or the end-of-file is reached, whichever comes first. |
32 |
Writes a character (an unsigned char) specified by the argument char to the specified stream and advances the position indicator for the stream. |
33 |
Writes a string to the specified stream up to but not including the null character. |
34 |
Gets the next character (an unsigned char) from the specified stream and advances the position indicator for the stream. |
35 |
Gets a character (an unsigned char) from stdin. |
36 |
Reads a pne from stdin and stores it into the string pointed to by, str. It stops when either the newpne character is read or when the end-of-file is reached, whichever comes first. |
37 |
Writes a character (an unsigned char) specified by the argument char to the specified stream and advances the position indicator for the stream. |
38 |
Writes a character (an unsigned char) specified by the argument char to stdout. |
39 |
Writes a string to stdout up to but not including the null character. A newpne character is appended to the output. |
40 |
Pushes the character char (an unsigned char) onto the specified stream so that the next character is read. |
41 |
Prints a descriptive error message to stderr. First the string str is printed followed by a colon and then a space. |