FILE HANDLING IN C
TYPES OF FILES�
TEXT FILES�
TEXT FILES�
OPENING A FILE
2. BINARY FILES�
FILE OPERATIONS�
WORKING WITH FILES�
OPENING A FILE - FOR CREATION AND EDIT�
SYNTAX OF FOPEN()�
CREATE/OPEN A FILE
RETURN VALUE�
FILE OPENING MODES�
FILE ACCESS_MODE
FILE ACCESS_MODE
FCLOSE()
WRITE TO A FILE�
Function | Description |
Similar to printf(), this function uses formatted string and variable arguments list to print output to the file. | |
Prints the whole line in the file and a newline at the end. | |
Prints a single character into the file. | |
fputw() | Prints a number to the file. |
fwrite() | This function writes the specified number of bytes to the binary file. |
READING FROM A FILE�
READING FROM A FILE
Function | Description |
Use formatted string and variable arguments list to take input from a file. | |
Input the whole line from the file. | |
Reads a single character from the file. | |
fgetw() | Reads a number from a file. |
Reads the specified bytes of data from a binary file. |
READING AND WRITING TO A BINARY FILE�
WRITING TO A BINARY FILE�
SYNTAX
READING FROM A BINARY FILE�
GETTING DATA USING FSEEK()�
FSEEK
Position | Meaning |
SEEK_SET | Starts the offset from the beginning of the file. |
SEEK_END | Starts the offset from the end of the file. |
SEEK_CUR | Starts the offset from the current location of the cursor in the file. |
SYNTAX OF FSEEK()�
FTELL()
FGETC()
FGETS() FUNCTION
FSCANF (FILE SCAN FORMATTED):�