Answer to Question #224692 in C++ for Lohith

Question #224692
Write c++ Program using files for employees
1
Expert's answer
2021-08-09T16:25:47-0400
#include<iostream>
#include<iomanip>
#include<fstream>
using namespace std;


int main(){
ofstream out;
out.open("Employee.txt", ios::out);
int n;
cout<<"Enter the number you want to store their information\n";
cin>>n;
for(int i=1; i<=n; i++){
	string name, pnumber, age, id;
cout<<"Enter employee name \n ";
cin>>name;
cout<<"Enter the emploee phone number\n";
cin>>pnumber;
cout<<"Enter the employee age\n";
cin>>age;
cout<<"Enter the employee id \n";
cin>>id;
out<<name<<"\t"<<pnumber<<"\t"<<age<<"\t"<<id<<endl;
}
out.close();
//Reading the employee data from Employee.txt;
ifstream streamIn("Employee.txt");
string str;
while(getline(streamIn, str)){
	cout<<str<<endl;
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS