cppbuzz logo

Home  |  About Us  |  Contact
View Questions Upload Training Misc..

Program: Program to read a text fil line by line
Author: CppBuzz
Date: 17th Nov 2017

#include <stdio.h>

int main(int argc, char* argv[])
    //pass the filename as argument
    char const* const fileName = argv[1]; 
    FILE* file = fopen(fileName, "r"); 
    char line[500];

    while (fgets(line, sizeof(line), file)) {
       printf("%s", line); 
    return 0;