What is header file #include ?
*The C programming language provides many standard library functions for file input and output. These functions make up the bulk of the C standard library header <stdio.h>.
- The first thing you will notice is the first line of the file, the #include "stdio.h" line. This is very much like the #define the preprocessor , except that instead of a simple substitution, an entire file is read in at this point.
- The system will find the file named "stdio.h" and read its entire contents in, replacing this statement.
- Obviously then, the file named "stdio.h" must contain valid C source statements that can be compiled as part of a program.
- This particular file is composed of several standard #defines to define some of the standard I/O operations.
- The file is called a header file and you will find several different header files on the source disks that came with your C compiler.
- Each of the header files has a specific purpose and any or all of them can be included in any program.
- Your C compiler uses the double quote marks to indicate that the search for the "include" file will begin in the current directory, and if it not found there, the search will continue in the "include" directory as set up in the environment.
- It also uses the "less than" and "greater than" signs to indicate that the file search should begin in the directory specified in the environment.
- Most of the programs in this tutorial have the double quotes in the "include" statements. The next program uses the "<" and ">" to illustrate the usage.
- Note that this will result is a slightly faster (but probably unnoticeable) compilation because the system will not bother to search the current directory.
********All C inbuilt functions which are declared in stdio.h header file are given below.********
List of inbuilt C functions in stdio.h file:- printf() This function is used to print the character, string, float, integer, octal and hexadecimal values onto the output screen
- scanf() This function is used to read a character, string, numeric data from keyboard.
- getc() It reads character from file
- gets() It reads line from keyboard
- getchar() It reads character from keyboard
- puts() It writes line to o/p screen
- putchar() It writes a character to screen
- clearerr() This function clears the error indicators
- f open() All file handling functions are defined in stdio.h header file
- f close() closes an opened file
- getw() reads an integer from file
- putw() writes an integer to file
- f getc() reads a character from file
- putc() writes a character to file
- f putc() writes a character to file
- f gets() reads string from a file, one line at a time
- f puts() writes string to a file
- f eof() finds end of file
- f getchar reads a character from keyboard
- f getc() reads a character from file
- f printf() writes formatted data to a file
- f scanf() reads formatted data from a file
- f getchar reads a character from keyboard
- f putchar writes a character from keyboard
- f seek() moves file pointer position to given location
- SEEK_SET moves file pointer position to the beginning of the file
- SEEK_CUR moves file pointer position to given location
- SEEK_END moves file pointer position to the end of file.
- f tell() gives current position of file pointer
- rewind() moves file pointer position to the beginning of the file
- putc() writes a character to file
- sprint() writes formatted output to string
- sscanf() Reads formatted input from a string
- remove() deletes a file
- fflush() flushes a file
No comments