Professional Documents
Culture Documents
10 File-1
10 File-1
10 File-1
#include<fstream>
#include<string>
using namespace std;
int main()
{
string str,s;
int a,b;
ofstream a_file ("example.txt");
a_file<<"This text will be inside of example.txt";
a_file<<"Welcome to DPES";
cout<<"\n Enter Name: ";
cin>>s;
a_file<<s<<" ";
cout<<"\n Enter Roll NO.: ";
cin>>a;
a_file<<a<<" ";
cout<<"\n Enter your Marks: ";
cin>>b;
a_file<<b<<"\n";
a_file.close();
ifstream b_file("example.txt");
if(b_file.is_open())
{
while(getline(b_file,str))
{
cout<<str<<"\n";
}
b_file.close();
}
cin.get();
}