When i load data into an array, I want it to find errors from the input (invalid character for quantity and price). I know a flush should be used to "flush" the rest of the line and an attempt to continue to the next line.
The code i wrote is:
Any help of this would be apprecited.....thanks!Code:... fsinventoryFile>> invArray[index].itemCode;. ... ... while(!fsinventoryFile.eof() ) { //begin read from file fsinventoryFile >> invArray[index].quantity >> invArray[index].price; cout<<"Record " <<index << " item code is:\t " <<invArray[index].itemCode <<endl; cout<<"Record " <<index << " quantity is:\t " <<invArray[index].quantity<<endl; cout<<"Record " <<index << " price is:\t " <<invArray[index].price<<endl; while(!(invArray[index].price ) || (fsinventoryFile >> invArray[index].quantity)) { cin.clear(); while(cin.get(aCh) && aCh !='\n'); //flush cout <<"Invalid input on: " <<invArray[index].itemCode << flush<<endl; } index++; fsinventoryFile>> invArray[index].itemCode; }//end-while