| File Reading and Writing Hi! Thanks for helping me. I need to write a program (in C++) that reads the file Employee.dat as input and then outputs to 4 different files which are Managers.dat, Marketing.dat, Developers.dat, and Testers.dat. Each of the output files contains the name of the employees of its category.
The fle Employee.dat contains following data:
Sue Leon 4
Robert Wise 3
Sam Woo 1
Nathan White 3
Suzan Head 2
Henry Williams 4
Christine Mint 1
Kim Leeds 4
Elton Sue 3
Ken Latch 2
I tried to write the program but I don't know what to put in "SWITCH" loop. Here is what i have so far.
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{
string line;
ifstream in_stream;
ofstream out_stream;
in_stream.open("Employee.dat");
if (in_stream.fail())
{
cout << "Input file failed to open.\n";
exit(1);
}
ofstream("Managers.dat", ios::app),
("Marketing.dat", ios::app),
("Developers.dat", ios::app),
("Testers.dat", ios::app);
if (out_stream.fail())
{
cout << "Output file failed to open.\n";
exit(1);
}
string first_name, last_name;
int departmnet;
enum department { Managers = 1, Marketing = 2, Developers = 3, Testers = 4 };
in_stream >> first_name >> last_name;
while (!in_stream.eof())
{
in_stream >> first_name >> last_name;
switch (department)//error C2059: syntax error : ')'
{//error : missing ';' before '{'
case 1://error: illegal case
cout << first_name << last_name;
break;
case 2://error: illegal case
cout << first_name << last_name;
break;
case 3://error: illegal case
cout << first_name << last_name;
break;
case 4://error: illegal case
cout << first_name << last_name;
}
}
return 0;
} |