Please help, this is for an assignment I need to turn in and I'm STUCK!
I have no idea how to do this I've done programs but none like this calling differnt functions. this is what is in the data file.
100 Hammer 10 20 10
200 Saw 24 00 12
300 Screwdriver 12 36 11
400 Pliers 40 00 25
500 Drill 24 12 13
600 Wrench 16 05 10
000 End_of_File 00 00 00
EOJ
Here is my code. I got it to ouput reading the file as char even though the numbers are suppose to be int, but every time i try to do the variables as int it outputs a never ending number. and I'm supposed to acummulate the totals on hand and total on order.
Also I must calculate the potential quantity wish is the total number on hand + on order - sold
I'm really just lost as to why it wont read my data file as int, that would help if i could figure that out, and hopefully i'll be able to figure out the rest.
//Preprocessive directives
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
//Prototypes
void initialization();
void process ();
void eoj ();
void openIt();
void readIt();
void writeIt();
ifstream inputFile;
char itemNum[4];
char itemDescription[15];
char qtyOnHand[2];
char qtyOnOrder[2];
char qtySold[2];
void main(void)
{
cout << "\n\t\tGWINNET TOOLS INC.\n\n";
cout << "Ref# Description OnHand OnOrder Sold\n";
cout << "--------------------------------------------\n";
initialization();
while (!inputFile.eof())
{
process();
}
eoj();
cout << "\n-----<E N D O F R U N>-----\n";
return;
}
void initialization()
{
openIt();
readIt();
return;
}
void process ()
{
writeIt();
readIt();
return;
}
void eoj ()
{
inputFile.close();
return;
}
void openIt()
{
inputFile.open("c:\\invent.dat");
if (inputFile.fail())
cout << "Names file open failed" << endl;
return;
}
void readIt()
{
inputFile >> itemNum >> itemDescription >> qtyOnHand >>
qtyOnOrder >> qtySold;
return;
}
void calculate()
{
}
void accumulate()
{
}
void writeIt()
{
cout << setw(6) << left<< itemNum << setw(15) << itemDescription << setw(8) << qtyOnHand
<< setw(8) << qtyOnOrder << setw(5) << qtySold << setw(5) << endl;
return;
}