Monday, May 10, 2021

simple program using ifstream in file handling (OOP) (93)

#include<iostream>

#include<fstream>

using namespace std;

int main()

{

ifstream obj;

string line;

obj.open("ofstreamExample.txt");

if(!obj)

{

cout<<"file does not exist:"<<endl;

}

while(getline(obj,line))

{

cout<<line<<endl;

}

obj.close();

} 

No comments:

Post a Comment