Here you will get C program to read file line by line.
In below program we first open a demo file hello.txt with some text in read mode. Make sure the file is already present. Then we read the file character by character and display on screen.
Program
#include<stdio.h> #include<conio.h> #include<stdlib.h> int main() { FILE *fp; char ch; fp = fopen("hello.txt","r"); if(fp == NULL) { printf("File not found. \n"); } else { printf("File is opening..... \n\n"); while((ch = fgetc(fp)) != EOF ) { printf("%c", ch); } } fclose(fp); return 0; }
Output
The post C Program to Read File Line by Line appeared first on The Crazy Programmer.
from The Crazy Programmer https://www.thecrazyprogrammer.com/2018/08/c-program-to-read-file-line-by-line.html
Comments
Post a Comment