you can add, delete an item since I have a fixed array struct member. |
There's your problem. You can't have it both ways. You need a variable length structure like a vector if you want to add new items.
Also, you have a lot of duplicate code. Instead of 8
display_xyz()
functions, there should be just one with a parameter that is the collection of items to display. The same is true of the
insert_data_xyz()
functions.
Because you also open 9 files, I assume that the data is supposed to be in the files, not hard-coded in the program.
Also, you have separate arrays for item names and item prices. Since everything has a price, it seems to me that all of your data for components should be based on a structure like:
1 2 3 4
|
struct Item {
string name;
double price;
};
|
As an aside, this brings up an important point: when writing a program, it's usually a good idea to start by figuring out how to represent the data. Then you can work on the code that manipulates that data.
I don't want to suggest anything further without knowing exactly what you're trying to accomplish. Please post the assignment so we can see what you're trying to do. The code just shows us how you're trying to do it.