Reading data from a file..
I am attempting to read data from a file but am having some troubles.
My data file is labeled LAB5.DAT
and its info is the following, exactly:
My goal here is to read in the first two letters/numbers, then the next one by itself, then the following 8.
Part number- 10
Division - A
Bin # - 111AX145
Then read in the description, then the price.
I have successfully written the program to read in the first line of data into the correct variables but cannot figure out how to read in the dscription or price, because they are on seperate lines. Here is my program so far...
LAB5 >> setw(3) >> department;
LAB5 >> setw(2) >> bin;
LAB5 >> setw(9) >> part_number;
LAB5 >> setw(5) >> unit_price;
cout << "department = " << department << endl;
cout << "bin = " << bin << endl;
cout << "part_number = " << part_number << endl;
cout << "description = " << description << endl;
cout << "unit price = $" << unit_price << endl;
When I compile and execute the program, this is how it reads:
department = 10
bin = A
part_number = 111AX145
unit price = $0
*Please help. Not sure what im doing wrong!*