My second issue is that all the functions except the add function need to be a submenu. I can't find an example online that truly helps me understand what I need to do. If anyone would be willing to show me how to put one of my functions in a submenu I will do the rest.
EDIT: I didn't read the code careful enough so I suspect my answer is not what you want. See jlb's answer instead.
The Inventory object inside the Add function is a local variable. It is created on line 74 and is destroyed on line 100 when the function ends. It has nothing to do with the Inventory object inside the Display function.
If you want both functions to use the same Inventory object you could use global variable, or you could declare create it in main and pass it as a function argument to the functions that needs it.
Let's start with your Add() function. First you need to be sure the file exists because the fstream with the open mode you specified will not create a file if it doesn't already exist. You should always check that the file opens properly before you try to read or write from the file. My suggestion is to stop using the fstream and use ofstream when do output and ifstream when doing input. The ofstream by default will create a file if it doesn't exist, but you do need to use an open mode that doesn't erase the file contents when it opens, use ios::app to keep the file contents.
And don't forget that the extraction operator stops processing strings when it encounters a white space character, you should consider using getline() instead. And if you do stick with the extraction operator be sure you limit the number of characters that will be extracted using the setw() function to avoid possible buffer overruns.
void Add()
{
system("CLS"); //clears screen
//fstream fout; // Not needed, see below,.
constint size = 3;
char ch;
int i = 0;
ofstream fout("Records.txt", ios::app); // Use the constructor to open the file whenever possible.
if(!fout) // Check to insure the file opened.
{
cerr << "Failed to open the output file.\n";
return; // No sense going on, since the file didn't open.
}
Inventory inv;
do
{
cout << "Enter title: " << endl;
cin.ignore();
cin >> setw(35) > inv.title;
...
// fout.close(); // Not needed, let the destructor do it's job.
}