nrk009

oops ass 10 file handling

Oct 2nd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. using namespace std;
  4. int main()
  5. {
  6.     char name[20],post[20],y[20];
  7.     int salary,months;
  8.     ofstream out("employee.txt");
  9.     cout<<"\nEnter employee name:";
  10.     cin.getline(name,20);
  11.     out<<name<<"\n";
  12.     cout<<"\nEnter the post(Manager/Worker/Hr):";
  13.     cin.getline(post,20);
  14.     out<<post<<"\n";
  15.     cout<<"\nEnter the months worked:";
  16.     cin>>months;
  17.     out<<months<<"\n";
  18.     cout<<"\nEnter monthly salary:";
  19.     cin>>salary;
  20.     out<<salary<<"\n";
  21.     out.close();
  22.     cout<<"\n\n";
  23.     cout<<"...employee details...\n";
  24.     ifstream in("employee.txt");
  25.     in>>name;
  26.     cout<<"Employee name:"<<name;
  27.     in>>post;
  28.     cout<<"\nPost of employee:"<<post;
  29.     in>>months;
  30.     cout<<"\nNumber of months worked:"<<months;
  31.     in>>salary;
  32.     cout<<"\nTotal salary:"<<salary*months;
  33.  
  34.     in.close();
  35.  
  36. }
Add Comment
Please, Sign In to add comment