5 Christine Kim...... 30.00 2 1 F
15 Ray Allrich 10.25 0 0 M
16 Adrian Bailey 12.50 0 0 F
with exactly 20 characters from the start of the name to the null before the double.
using
Expand|Select|Wrap|Line Numbers
- int empNum,
- empDep,
- empTyp;
- char empNam[MAX_CHARS];
- double empRat;
- ifstream inEmp;
- inEmp.open("master7.txt");
- if (!inEmp)
- {
- cout << "\n\nError opening the file!!" << endl;
- exit(1);
- }
- inEmp >> empNum;
- inEmp.ignore(1, '\0');
- inEmp.getline(empNam, MAX_CHARS);
- inEmp >> empRat >> empDep >> empTyp;
- cout << "\nNum: " << empNum << "\nName: " << empNam[0] << empNam[1] << empNam[2]
- << "\nRat: " << empRat << "\nDep: " << empDep << "\nType :" << empTyp;
- system("PAUSE");
my output is as follows:
Num: 5
Name: Chr
Rat: -9.25596e+61
Dep: -858993460
Type :-858993460Press any key to continue . . .
why can't I get a good read for my double empRat?