stdio.h in C

The header file named stdio.h in Standard C Library defines three variable types, a number of macros and various functions to implement input and output.

stdio.h in C

The header file named stdio.h in Standard C Library defines three variable types, a number of macros and various functions to implement input and output.

The variables are defined in stdio.h

The following lists some types of variables defined in stdio.h in Library C:

Description variable size_t

This is an unsigned integer type and the result of the sizeof keyword

FILE

This is a suitable type of object to store information for a File Stream

fpos_t

This is a type of object suitable for storing any location in a File

The macros are defined in stdio.h

The table below lists some macros defined in stdio.h in Library C:

Macro Description NULL

This macro is the value of a null pointer constant

_IOFBF, _IOLBF and _IONBF

These are macros that develop integer constant expressions with separate and appropriate values ​​to use as the third parameter for setvbuf function

BUFSIZ

This macro is an integer, which represents the size of the Buffer used by the setbuf function

EOF

This macro is a vowel number, only that has reached End-Of-File

FOPEN_MAX

This macro is an integer, representing the maximum number of files that the system can guarantee to be opened simultaneously

FILENAME_MAX

This macro is an integer, representing the longest length of an appropriate character array to store the filename as long as possible. If the implementer is unlimited, then this value should be the recommended maximum value

L_tmpnam

This macro is an integer, representing the longest length of an appropriate character array to store the longest temporary filename possible, created by the tmpnam function.

SEEK_CUR, SEEK_END, and SEEK_SET

This macro is used in the fseek function to identify different locations in a File

TMP_MAX

This macro is the maximum number of unique filenames that tmpnam can create

stderr, stdin, and stdout

These macros are pointers to FILE types corresponding to Standard Error, Standard Input and Standard Output Stream

Functions defined in stdio.h

Here are some functions defined in stdio.h in Library C:

STD & Description1

Int fclose function (FILE * stream)

Close the Stream. All Buffers are Flush (wipe or transfer to the periphery)

2

Void clearerr function (FILE * stream)

Delete end-of-file and error indicator for the given Stream

3

Int feof function (FILE * stream)

Check the end-of-file indicator for the given Stream

4

Int ferror function (FILE * stream)

Check the error indicator for the given Stream

5

Int fflush function (FILE * stream)

Flush the output buffer of a Stream

6

Int fgetpos function (FILE * stream, fpos_t * pos)

Take the current location of the Stream file and burn it to pos

7

Function FILE * fopen (const char * filename, const char * mode)

Open the file name pointed to the filename parameter by using the given mode mode

8

Function size_t fread (void * ptr, size_t size, size_t nmemb, FILE * stream)

Read data from Stream given in array pointed by ptr

9

Function FILE * freopen (const char * filename, const char * mode, FILE * stream)

Mount a new filename with the given Stream and at the same time close the old FILE in the Stream

ten

Int fseek (FILE * stream, long int offset, int whence)

Set Stream's file position to the given offset. The offset parameter specifies the number of bytes to search from where the given location is

11

Int fsetpos function (FILE * stream, const fpos_t * pos)

Set the file location of the stream to the given location. The pos parameter is a location provided by the fgetpos function

twelfth

Long int ftell function (FILE * stream)

Returns the current file location of the given Stream

13

Function size_t fwrite (const void * ptr, size_t size, size_t nmemb, FILE * stream)

Write data from the array pointed by ptr to the given Stream

14

Int remove function (const char * filename)

Delete the filename given so that it is no longer accessible

15

Int rename function (const char * old_filename, const char * new_filename)

Make the filename referenced, changed from old_filename to new_filename

16

Void rewind function (FILE * stream)

Set the file location to the beginning of the file in the given Stream

17

Function void setbuf (* stream, char * buffer FILE)

Defining how a Stream should be buffered (buffer)

18

Int setvbuf function (FILE * stream, char * buffer, int mode, size_t size)

Another function to determine how a Stream should be buffered (buffer)

19

Function FILE * tmpfile (void)

Create temporary files in wb + mode

20

Char * tmpnam function (char * str)

Create and return a valid temporary filename (does not exist before creating)

21

Int fprintf function (FILE * stream, const char * format, .)

Send formatted output to a Stream

22

Function int printf (const char * format, .)

Send formatted output to a stdout

23

Int sprintf function (char * str, const char * format, .)

Send formatted output to a string string

24

Int vfprintf (FILE * stream, const char * format, va_list arg)

Send formatted output to a stream using a parameter list

25

Int vprintf function (const char * format, va_list arg)

Send formatted output to a stdout using a parameter list

26

Int vsprintf function (char * str, const char * format, va_list arg)

Send formatted output to a string string by using a parameter list

27

Int fscanf function (FILE * stream, const char * format, .)

Read input that has been formatted from a Stream

28

Int scanf function (const char * format, .)

Read input has been formatted from stdin

29

Function int sscanf (const char * str, const char * format, .)

Read the formatted input from a string string

30

Int fgetc function (FILE * stream)

Take the next character (an unsigned char) from the given Stream and increase the position indicator for that Stream

thirty first

Char * fgets (char * str, int n, FILE * stream)

Read a line from the given Stream and store it in the string pointed by str. It stops when any of the following conditions are encountered: (n-1) the character has been read, the newline character (new line) is read or caught end-of-file

32

Int fputc (int char, FILE * stream)

Writing a character (an unsigned char) was determined by the char parameter to the given Stream and increased the position indicator for the Stream

33

Function int fputs (const char * str, FILE * stream)

Write a string to the specified Stream (do not write null characters)

34

Int getc function (FILE * stream)

Take the next character (an unsigned char) from the given Stream and increase the position indicator for that Stream

35

Int getchar (void) function

Get a character (an unsigned char) from stdin

36

Char * gets function (char * str)

Read a line from stdin and store it inside the string pointed by str. It stops when the end-of-file or newline character is encountered (new line) is read

37

Int putc (int char, FILE * stream)

Write a character (an unsigned char) defined by the char parameter to the given Stream and increase the position indicator for that Stream

38

Int putchar (int char) function

Writing a character (an unsigned char) has been defined by the char parameter to stdout

39

Function int puts (const char * str)

Write a str string to stdout (do not write null characters). A newline character (new line) is appended to the output

40

Int ungetc function (int char, FILE * stream)

Push the char character (an unsigned char) on the Stream given to the next character to be read

41

Function void perror (const char * str)

Print a message describing the error to stderr. First, the printed string str is followed by a colon and then a space

According to Tutorialspoint

Last lesson: stddef.h in C

Next lesson: The function fclose () in C

Update 25 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile