This is my program that will ask the user for a list of apps and will store that info and later display it back to them. However it needs to prompt them what is the NAME of the file they are working with first. I basically have an outline of the program but I'm stuck on the part where it prompts them for the file. Every time it askes them for the name of the file and you enter something it closes out the program. Any help would be nice :D
// Purpose of the program...
// is to manage an array of apps
// providing a way to read and display
// using structures and functions
//Create constants used as array sizes
const int SIZE_TITLE = 131;
const int SIZE_DESC = 300;
const int SIZE_PAGE = 6;
//This creates a grouping for an individual app
struct app
{
char name[SIZE_TITLE];
char description[SIZE_DESC];
char page[SIZE_PAGE];
int length;
};
void displayall(app &); //display all members
void getfilename(char filename[]); //function for getting the external data file
void readall(app &); //reads the input
bool save_app(char filename[], app[], int num);
bool load_app(char filename[], app[], int & num);
void choice(char & x);
int main ()
{
app user[15]; //collection of apps for the user
char filename[35]; //holds the file name
int num_apps=0; //number of apps in the array
char rerun;
getfilename(filename);
if(!load_app(filename, user, num_apps));
cout<<"we are starting from stratch!";
int i = num_apps;
readall(user[i]);
return 0;
}
//Ask the user what file they want to work with
void getfilename(char array[])
{
cout<<"Please enter the name of a file limited to 31 characters: ";
cin>>array;
strcat(array,".txt");
}
//read in all the users apps
void readall(app & user_list)
{
cout<<"Please enter the title: ";
cin.get(user_list.name,131,'\n');
}
//write all of the movies OUT to a file
bool save_app(char filename[], app apps[], int num)
{
bool success = true;
ofstream write;
write.open(filename);