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....
any help on this would be great....thx
fsinventoryFile >> invArray[index].quantity
while((!invArray[index].price ) || (!invArray[index].quantity))
while(cin.get(aCh) && aCh !='\n');
cout <<"Invalid input on: "
cout<<"Record " <<index << " item code is:\t "
<<invArray [index].itemCode <<endl;
cout<<"Record " <<index << " quantity is:\t "
cout<<"Record " <<index << " price is:\t "
}//end of while loop
Code tags added by kermi3
I am posting this because you did not use code tags on this thread. In the furture please use Code Tags. They make your code MUCH easier to read and people will be much more likely to help you if you do. And they'll be happy about helping you ;)
Without code tags:
cout << "No code tags are bad";
With Code Tags:
This is of course a basic example...more complicated code is even easier to read with code tags than without.
cout << "This code is easy to read";
I've added code tags for you this time. They can be added by putting [code] at the beginning of your code and [/code] at the end. More information on code tags may be found at the link in my signature. I also suggest you take a look at the board guildlines if you have not done so already. Any further questions or ways I can help please feel free to PM me.
This is a common first post mistake, just remember to use [code] tags in the future and you'll get much more help.