//To Keep Previous Data in File Replace World "out" with "app" in Line#7.
#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
int main()
{
ofstream outClientFile("BSSE.txt", ios::out);
if(!outClientFile)
{
cerr<<"\n\tFile Oppening Error...!"<<endl; //error mxg in Case of File Creating Failed...
}
char name[15];
int rollNo;
float gpa;
outClientFile<<"ROLL NO."<<setw(9)<<"NAME"<<setw(11)<<"GPA\n";
cout<<"\n\t** Enter ^Z to END input **\n";
cout<<"\n > Enter RoolNo, Name and GPA: ";
while(cin>>rollNo>>name>>gpa)
{
outClientFile<<" "<<rollNo<<setw(9)<<" "<<name<<setw(11)<<" "<<gpa<<endl;
cout<<"\n > Enter RoolNo, Name and GPA: ";
}
cout<<"\n\t\tDONE...!\n";
system("pause");
}
#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
int main()
{
ofstream outClientFile("BSSE.txt", ios::out);
if(!outClientFile)
{
cerr<<"\n\tFile Oppening Error...!"<<endl; //error mxg in Case of File Creating Failed...
}
char name[15];
int rollNo;
float gpa;
outClientFile<<"ROLL NO."<<setw(9)<<"NAME"<<setw(11)<<"GPA\n";
cout<<"\n\t** Enter ^Z to END input **\n";
cout<<"\n > Enter RoolNo, Name and GPA: ";
while(cin>>rollNo>>name>>gpa)
{
outClientFile<<" "<<rollNo<<setw(9)<<" "<<name<<setw(11)<<" "<<gpa<<endl;
cout<<"\n > Enter RoolNo, Name and GPA: ";
}
cout<<"\n\t\tDONE...!\n";
system("pause");
}
0 comments: