External Data file basic in and output

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

#include <iostream>
#include <fstream>
using namespace std;
#include <cstring>
#include <cctype>

//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;

if(!load_app(filename, user, num_apps));
cout<<"we are starting from stratch!";

int i = num_apps;

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: ";


//read in all the users apps
void readall(app & user_list)
cout<<"Please enter the title: ";

//write all of the movies OUT to a file
bool save_app(char filename[], app apps[], int num)
bool success = true;
ofstream write;

if (!write)
cout <<"Can't save, try agian \n\n";
success = false;
for(int i=0; i < num; ++i)
write <<apps[i].name <<"|" <<endl;
return success;

//load all movies FROM an external file
bool load_app(char filename[], app apps[], int & num)
ifstream read;

return false;

return true;

//later be used for a loop
void choice(char & x)
cout<<"Would you like to add more data?(N or Y) ";
Topic archived. No new replies allowed.