//Inventory Control #include //iostream is a subset of fstream. #include //to use strlen #include //to use setw void getItem2(char prod[], int &quan, double &price); //input as 1 line void getItem(char prod[], int &quan, double &price); //add one item from keyboard void printList(char product[][12],int quantity[], double price[], int count); void spaces(int num); void readFile(char product[][12],int quantity[], double price[], int &count); void getFileItem(char prod[], int &quan, double &price, ifstream &input); void main (void) //main has 3 arrays and count that are passed to other functions { char product[20][12]={"Widget","Dodad","Thingamajig", "Dohicky"}; int quantity[20] = {20, 100, 12, 40}; double price[20] = {12.95, 7.50, 1.25, 6.00}; int count=0; readFile(product,quantity,price,count); printList(product,quantity,price,count); } //main void getItem2(char prod[], int &quan, double &price) //input as 1 line { //line of input will be: product; quantity; price\n cout<<"Enter name of product; quantity; price:"; cin.getline(prod,12,';'); //stop at the ; if (strlen(prod)==11) //maximum letters read, get rid of extra letters and ; cin.ignore(40,';'); cin>>quan; cin>>price; cin.ignore(100,'\n'); //ignore rest of line trailing blanks and \n } //getItem void getItem(char prod[], int &quan, double &price) //add one item from keyboard { cout<<"Enter name of product:"; cin.getline(prod,11,'\n'); if (strlen(prod)==11) //maximum letters read, get rid of \n cin.ignore(100,'\n'); cout<<"Enter quantity:"; cin>>quan; cout<<"Enter price:"; cin>>price; cin.ignore(100,'\n'); } //getItem void spaces(int num) { for(int i=0; i>quan; input>>price; input.ignore(100,'\n'); //ignore rest of line trailing blanks and \n } //getFileItem