Hello,
I am trying to read data from a text file in the following format:
05 mike smith 30.00 2 1
so the format is: int, character[21] = max size of array, double, int, int
I am trying to read the values into an array of objects. I can read the first int and the name fine but I can't read in the rest of the values. Heres my code:
numEmp = 0;
empFile >> id;
empFile.ignore(); // Discard space before name
empFile.getline(name, 21, '\n'); // Store up to 20 characters
empFile >> rate >> dep >> type; //I think this is the problem
while (empFile && numEmp < MAX_EMP)
{
// Move new employee info into array and increment numEmp count
Emp[numEmp].set(id, name, rate, dep, type);
numEmp++;
// Get next employee info
empFile >> id;
outputFile << id << endl;
empFile.ignore(); // Discard space before name
empFile.getline(name, 21, '\n'); // Store up to 20 characters
empFile >> rate >> dep >> type;
}