Programming

Write a C++ Program to Read a File

Write a C++ Program to Read a File.

Source Code

#include<fstream>

#include<iostream>

#include<conio.h>

using namespace std;

int main()

{

    char buffer[100];

    int maxlength=100;

    ifstream fin("myfile.txt");

while (fin)

    {

    fin.getline(buffer,maxlength);

    cout<<buffer<<endl;

    }

    fin.close();

    getch();

}

Tuts

About Author

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.