File Handing
#include<iostream>;
#include<fstream>;
#include<string>
using namespace std;
int main() {
//ofstream file_obj("abc1.doc");//Create file and open
////fstream file_obj("abc1.txt",ios::in|ios::app);
//
//if (file_obj.is_open()) {
// file_obj << " This is word Doc";
// file_obj.close();
//}
//else
//{
// cout << "file not found";
//}
ifstream file_obj("abc1.txt");
string data;
if (file_obj.is_open()) {
while (getline(file_obj,data))
{
cout << data;
}
}
else
{
}
return 0;
}
Comments
Post a Comment