//program to read record of an employee from an existing file (emp.txt)
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int id;
char name[20],address[20];
float salary;
ifstream in("emp.txt");
cout<<endl<<"Reading from file....";
in>>id>>name>>address>>salary;
cout<<endl<<"Displaying record of an employee: ";
cout<<endl<<"ID: "<<id;
cout<<endl<<"Name: "<<name;
cout<<endl<<"Address: "<<address;
cout<<endl<<"Salary: "<<salary;
in.close();
return 0;
}
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int id;
char name[20],address[20];
float salary;
ifstream in("emp.txt");
cout<<endl<<"Reading from file....";
in>>id>>name>>address>>salary;
cout<<endl<<"Displaying record of an employee: ";
cout<<endl<<"ID: "<<id;
cout<<endl<<"Name: "<<name;
cout<<endl<<"Address: "<<address;
cout<<endl<<"Salary: "<<salary;
in.close();
return 0;
}
No comments:
Post a Comment