C/C++ Help
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Remember me

Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
Unread Dev Articles Community Forums Sponsor:
Old November 25th, 2012, 04:14 AM
lazyman lazyman is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
Join Date: Nov 2012
Posts: 1 lazyman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 29 sec
Reputation Power: 0
External data file

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

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

Reply With Quote

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > External data file

Developer Shed Advertisers and Affiliates

Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap