#include<iostream>
#include<fstream>
#include<string>
using namespace std;
string name; int sem; double cgpa;
void write()
{
ofstream flobj("file.txt");
if(flobj.is_open())
{
cout <<"enter your name, number of semester and CGPA." <<endl;
cout <<"and press Ctrl+Z and Enter when you done.\n\n" <<endl;
while(cin>> name>> sem>> cgpa)
{
flobj <<name <<" " <<sem <<" " <<cgpa <<endl;
}
}
else
{
cout <<"aint workin, pal\n\n";
}
flobj.close();
}
void read()
{
ifstream flobj2("file.txt");
while(flobj2>> name>> sem>> cgpa)
{
cout <<"your name: "<<name;
cout <<".\nyou're on "<<sem <<" semester.";
cout <<"\nand your CGPA is: "<< cgpa<<".\n\n";
}
}
int main()
{
write();
read();
}
#include<fstream>
#include<string>
using namespace std;
string name; int sem; double cgpa;
void write()
{
ofstream flobj("file.txt");
if(flobj.is_open())
{
cout <<"enter your name, number of semester and CGPA." <<endl;
cout <<"and press Ctrl+Z and Enter when you done.\n\n" <<endl;
while(cin>> name>> sem>> cgpa)
{
flobj <<name <<" " <<sem <<" " <<cgpa <<endl;
}
}
else
{
cout <<"aint workin, pal\n\n";
}
flobj.close();
}
void read()
{
ifstream flobj2("file.txt");
while(flobj2>> name>> sem>> cgpa)
{
cout <<"your name: "<<name;
cout <<".\nyou're on "<<sem <<" semester.";
cout <<"\nand your CGPA is: "<< cgpa<<".\n\n";
}
}
int main()
{
write();
read();
}
No comments:
Post a Comment