Write a C++ Program to Read Write Lecturer Details using File Handling. Data members , Name, EmployeId, Department. Member functions are setter and getter function. Array of 3 lecturer data should be written and read in a file.
2. Make another file and read data from first file and write into second file in reverse order.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream fout;
string line;
fout.open("input.txt");
while (fout) {
getline(cin, line);
if (line == "-1")
break;
fout << line << endl;
}
fout.close();
ifstream fin;
fin.open("input.txt");
while (fin) {
getline(fin, line);
cout << line << endl;
}
fin.close();
return 0;
}
Comments
Leave a comment