File Handling in C (Reading a file line by line)
![Image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_LVN_4HcRhMC9GHg3bQpemwpua3oPlGHX-7qIrzFVw9veSi9XV69pRaPYhh74klWCe-83XUf3_GRQHviKO-HdQR1H21b_t8bnkowzvshNhPNocV8yPCALUag5TVD5M4lYhLoJj5g8LQMF/s640/writelogo.png)
In this tutorial, we are working with the files in the C. File handling in any language requires Three main steps to follow Open the file in Read/Write mode. Do various operation that you want to do. Close the file. We are using fopen(file stream). there is some modes to open a file. Read mode opens file into the read mode if file not found returns -1. Write mode opens file into the write mode if the file does not present creates a new file if there is previous data it will be overwritten. Append mode opens the file in the append mode and append data to it Without wasting much time lets start working. Create a New C file of whatever name you want mine is files.c. create the basic schema of C language. #include <stdio.h> int main(int argc, char const *argv[]) { /* code */ return 0; } Read From the file Create a FILE pointer to point a stream and open a file into the read mode using "r". you may need to include the string.h to your headers. the data of the file is #in