C Program To Read A Line By Line And Write Line By Line Using File

/* Program to read a text file line by line Author: CppBuzz Date: 17th Nov 2017 */
#include <stdio.h>
int main(int argc, char* argv[])
//read any text file from currect directory
char const* const fileName = "hello.txt";
FILE* file = fopen(fileName, "r");
printf("\n Unable to open : %s ", fileName);
return -1;
char line[500];
while (fgets(line, sizeof(line), file)) {
printf("%s", line);
return 0;


Sharing Is Caring

Leave a Comment