While reading data from a file to be loaded into an array, if an error occurs ont he input....an error message should be displayed and the rest of the line should be flushed....and continue on with the next line.....the code I wrote is....
Code:
fsinventoryFile>> invArray[index].itemCode;
while(!fsinventoryFile.eof() )
{
fsinventoryFile >> invArray[index].quantity
>> invArray[index].price;
while((!invArray[index].price ) || (!invArray[index].quantity))
{
cin.clear();
while(cin.get(aCh) && aCh !='\n');
cout <<"Invalid input on: "
<<invArray[index].itemCode<<endl;
}
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;
index++;
fsinventoryFile>> invArray[index].itemCode;
}//end of while loop
any help on this would be great....thx
Code tags added by kermi3