Ask Experts Questions for FREE Help!
  Advanced
Register  |  Log in  
   Ask    
 Answer  
  Help  

Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
Free Answers in 3 Easy Steps

Register Now
3 Steps

At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.

Home > Computers & Technology > Programming > Compiled Languages > C++   »   File Reading and Writing

 
Question Tools Search this Question Display Modes
Question
 
 
#1  
Old Jul 7, 2008, 01:48 PM
idle_09
New Member
idle_09 is offline
 
Join Date: Mar 2008
Posts: 3
idle_09 See this member's comment history on his/her Profile page.
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;
}

Reply With Quote
 
     



Question Tools Search this Question
Search this Question:

Advanced Search
Display Modes

 
Similar Sponsors

Similar Questions
Question Asker Topic Answers Last Post
problems with reading from file albear C 2 Apr 4, 2008 04:19 PM
File W-7 form without tax return and why to file as a resident alien? Ankita84 Taxes 1 Mar 1, 2008 08:53 AM
how to improve reading and writing rita_7yy Reading & Writing 1 Oct 31, 2007 01:09 PM
Reading from an .mpp file prabu_507 Other Software 0 Jun 20, 2007 11:28 PM
Reading and Writing hamworld05 Children 6 Mar 4, 2007 12:02 PM




Copyright ©2003 - 2007, Ask Me Help Desk.
All times are GMT -8. The time now is 11:51 PM.

Content Relevant URLs by vBSEO 3.0.0 RC6 © 2006, Crawlability, Inc.