#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;
}
}
Comments
Leave a comment