Quote:
|
Originally Posted by soccer03
I'm trying to create a program that uses no global variables and a structure to store the following inventory data in a file:
Item description, quantity on hand, wholesale cost, retail cost, and date added to inventory.
|
...which means that any data structures created will
have to be passed about as a function parameter -- more precisely, it makes more sense pass data structures by address or reference
especially if a function modifies its value in any way.
Quote:
|
In all actuality I want the program to have a menu that allows the user to add, display and change any record in the file.
|
Is this a requirement of the assignment? Are all records to be read interactively? The point is not to make your work any more complicated than the requirements mandate.
Quote:
|
To make this program sensible it shouldn't accept any cost less than 0. It should also not accept any unreassonable dates. My teacher wants us to include a prodld integer field and ensure that it is in therange of 1-15. The prodId field should the record number within the file.
|
So it sounds like you will will want to enter a value followed by doing some range checking. One idea would be to put entry into a while loop which only exits if the above criteria has been met.
Quote:
|
For example, the product with the prodid value of 2 will be the second record in the file, the product with the prodId value of 5 will be the 5th record in the file.
|
One thing you will need to clarify with your instructor is whether he/she expects you to code the random access into the file yourself, or whether you want to maintain all records in memory. Obviously if you do the latter, your application will have an upper limit on how many records can be retained in memory. Random access into the file solves this problem, but can be a bit thorny for newcomers.