C++ 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();

}
Back to top button