Okay, so I've been working on my final for days, and I've gotten it to run without errors or crashing, but I have this little section here I'm having trouble with.
It seems to skip through the if else statements and just tells me invalid id everytime. I put the cout stuff above to test and it shows up as it should. why aren't the strcmp's doing their jobs?
**********************************
*________MENOCU TOOL SHOP________*
**********************************
* 1. Display Inventory *
* 2. Create a Transaction File *
* 3. Update Inventory *
* 4. Display Updated Inventory *
* 5. Compute Profit Projection *
* 6. EXIT *
**********************************
Menu Choice: 2
How many records to ammend: 1
Her are the Transaction Codes:
AI: Add to Inventory
RI: Reduce from Inventory
CW: Change Wholesale Cost
CR: Change Retail Price
CD: Change Description
Enter the ItemID #: 597895
Enter the Transaction Code: AI
Enter New Data: 54654
**********************************
*________MENOCU TOOL SHOP________*
**********************************
* 1. Display Inventory *
* 2. Create a Transaction File *
* 3. Update Inventory *
* 4. Display Updated Inventory *
* 5. Compute Profit Projection *
* 6. EXIT *
**********************************
Menu Choice: 3
597895 AI 54654
Invalid ItemID
Invalid ItemID
Invalid ItemID
Invalid ItemID
Invalid ItemID
I realize its running to many times, In my create transaction file I'm going to have the user choose how many entries they want to edit and get that into this function, but for now this is fine.
Clearly the file and read is working from the cout statements. but why is it failing the comparisons?
If you are seeing "Invalid ItemID", that is because inv[i].getID() == it.itID, from line 12, is false. Since line 12 is false, lines 13-30 will not be executed.
I am still trying to answer your original question:
It seems to skip through the if else statements and just tells me invalid id everytime. I put the cout stuff above to test and it shows up as it should. why aren't the strcmp's doing their jobs?
You should investigate why the condition that you thought would be true is actually false. In other words, investigate why inv[i].getID() != it.ID. Earlier you claimed that your "cout stuff" shows up as it should, but you only tested it.ID and did not include inv[i].getID() in your "cout stuff" tests.
Why are you reading the file when you should probably already have all the information in the inv[] array?
You really really need to simplify your functions. They should do as little as possible, ideally one thing, and do it well.
Is it an assignment requirement to use binary files? Using binary files, adds a lot of complication to the program, so if it's really not necessary then just go with regular old text files instead.
If you are required to use binary files, what exactly does your input file contain.
For your current problem you may want to insure that there are no hidden characters in either of your strings, check that the lengths() are the same and that the number of visible characters match the reported lengths.
The file comes from another function where the user chooses what ID, Transaction Code and Edited Data. The file is then used to update the existing array of class object. This is all solved now though. Thanks for everyone's input it was very helpful.