Answer to Question #286665 in C++ for Aleeza

Question #286665

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.

1
Expert's answer
2022-01-11T14:38:57-0500
#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;
}

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