Hi,
I am a CS student and currently have a lab that is due tomorrow, i've been confused and researching all week but still cant figure it out. I need to g++ compile on UNIX my c++ source with a input file redirection which I get but the issue is writing the c++ program and then accepting the input from the file.
The part of the assignment I am struggling with is that. Here is the information I have, and also what I have done. Im just hoping someone can point me in the right direction so I can figure this out.
--------------------------------------------------------------------
Program must read 10 employees information in format of
ID# FIRST LAST DOB . DATE OF HIRE PAY AND HOURS WORKED
input file looks like:
57383 JOHN DOE 10 20 1981 6 5 2005 8.75 36
compute gross pay / net pay after tax reduction
output info to console
struct EmployeeInfo {
int IDNUM, PAYRATE; // id number, pay rate
std::string FIRST, LAST; // first and last name
Date DOB;
Date DOH;
};
----------------------------------------------
and my main.cpp
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include "EmployeeInfo.h"
#define MAX 10
using namespace std;
int main()
{
char file[20];
int num;
ifstream fin;
do
{
fin.clear();
cout << "enter name of file to connect to" << endl;
cin.getline(file, 20);
fin.open(file);
fin >>num;
} while(!fin);
Okay so I write the program to compute all the gross pay and simple math and set string as cin and it automatically grabs the input from file as if the user typed it?