10 File-1

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include<iostream>

#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();
}

You might also like