|
From: DrNoose on 27 Mar 2006 12:17 Hi! I'm taking a class in c++ and am having to write a pretty big program that involves vectors, push-backs, etc. I'm trying to do this thing one step at a time to make sure everything works right. The problem I'm having is that when I go to run the program, all I see is "Press any key to continue", I don't see my menu. It builds okay without any errors. Can someone take a look and see what might be causing it not to show up on the screen. Thanks! /* Program Description: Program will keep track of a hardware store's inventory. The store sells various item.s For each item in the store, the following information is kept- item ID, item name, number of pieces ordered, number of pieces currently in the store, number of pieces sold, manufacturer's price for the item, and the store's selling price. At the end of each week, the store manager would like to see a report that shows the item ID, item name, pieces ordered, pieces in the store, pieces sold, manufacturers price and the selling price.*/ #include <iostream> #include <iomanip> #include <fstream> #include <string> #include <vector> using namespace std; // function prototypes void printMenu(); int main() { ifstream inFile; // input stream variable // variable declaration inFile.open ("e:\\cosc1437\\p2data.text"); // open data file if (!infile) { cout << "Input file (p2data.text) does not exist." << endl; return 1; } printMenu(); inFile.close(); return 0; } void printMenu() { cout << " ---------------------Menu--------------------" << endl << endl; cout << "Welcome to Kathy Gibson's Hardware Store!" << endl; cout << "Choose from the following menu options: " << endl << endl << endl << endl; cout << " 1: To see if an item is in the store " << endl; cout << " 2: To buy an item " endl; cout << " 3: To check the price of an item " << endl; cout << " 4: To print the inventory " << endl; cout << " 9: To end the program " << endl; }
From: Paul F. Johnson on 27 Mar 2006 12:37 DrNoose wrote: > I'm trying to do this thing one step at a time to make sure everything > works right. Good plan. > The problem I'm having is that when I go to run the program, all I see > is "Press any key to continue", I don't see my menu. It builds okay > without any errors. > #include <iostream> > #include <iomanip> > #include <fstream> > #include <string> > #include <vector> I take it that most of these headers are for use later on in the program? > using namespace std; > void printMenu(); Personal preference, have main() at the end - it avoids prototyping. > printMenu(); On my machine, it prints the menu (I've removed the infile bit for obviously reasons). What it could be is that you're running the program from within VisualStudio (assuming that's what it is you're using). That has a very nasty habit of not showing what is going on. Try opening a command window and running the program from within there. TTFN Paul
From: osmium on 27 Mar 2006 12:45 "DrNoose" wrote: > I'm taking a class in c++ and am having to write a pretty big program that > involves vectors, push-backs, etc. > > I'm trying to do this thing one step at a time to make sure everything > works right. > > The problem I'm having is that when I go to run the program, all I see is > "Press any key to continue", I don't see my menu. It builds okay without > any errors. > > Can someone take a look and see what might be causing it not to show up on > the screen. Almost works for me. Had to add one << as noted and take out the file stuff, since I don't have the file. That's on DevC. > Thanks! > > /* Program Description: Program will keep track of a hardware store's > inventory. The store sells various item.s For each item in the store, the > following information is kept- item ID, item name, number of pieces > ordered, number of pieces currently in the store, number of pieces sold, > manufacturer's price for the item, and the store's selling price. At the > end of each week, the store manager would like to see a report that shows > the item ID, item name, pieces ordered, pieces in the store, pieces sold, > manufacturers price and the selling price.*/ > > #include <iostream> > #include <iomanip> > #include <fstream> > #include <string> > #include <vector> > > using namespace std; > > // function prototypes > > void printMenu(); > > int main() > { > ifstream inFile; // input stream variable > > // variable declaration > > > inFile.open ("e:\\cosc1437\\p2data.text"); // open data file > if (!infile) > { > cout << "Input file (p2data.text) does not exist." << endl; > return 1; > } > > printMenu(); > > inFile.close(); > > return 0; > } > > void printMenu() > { > cout << " ---------------------Menu--------------------" << endl << > endl; > cout << "Welcome to Kathy Gibson's Hardware Store!" << endl; > cout << "Choose from the following menu options: " << endl << endl << endl > << endl; > cout << " 1: To see if an item is in the store " << endl; > cout << " 2: To buy an item " endl; missing << > cout << " 3: To check the price of an item " << endl; > cout << " 4: To print the inventory " << endl; > cout << " 9: To end the program " << endl; > > }
From: DrNoose on 27 Mar 2006 15:34 Thanks! Got that fixed! osmium wrote: > "DrNoose" wrote: > >> I'm taking a class in c++ and am having to write a pretty big program that >> involves vectors, push-backs, etc. >> >> I'm trying to do this thing one step at a time to make sure everything >> works right. >> >> The problem I'm having is that when I go to run the program, all I see is >> "Press any key to continue", I don't see my menu. It builds okay without >> any errors. >> >> Can someone take a look and see what might be causing it not to show up on >> the screen. > > Almost works for me. Had to add one << as noted and take out the file > stuff, since I don't have the file. > That's on DevC. > >> Thanks! >> >> /* Program Description: Program will keep track of a hardware store's >> inventory. The store sells various item.s For each item in the store, the >> following information is kept- item ID, item name, number of pieces >> ordered, number of pieces currently in the store, number of pieces sold, >> manufacturer's price for the item, and the store's selling price. At the >> end of each week, the store manager would like to see a report that shows >> the item ID, item name, pieces ordered, pieces in the store, pieces sold, >> manufacturers price and the selling price.*/ >> >> #include <iostream> >> #include <iomanip> >> #include <fstream> >> #include <string> >> #include <vector> >> >> using namespace std; >> >> // function prototypes >> >> void printMenu(); >> >> int main() >> { >> ifstream inFile; // input stream variable >> >> // variable declaration >> >> >> inFile.open ("e:\\cosc1437\\p2data.text"); // open data file >> if (!infile) >> { >> cout << "Input file (p2data.text) does not exist." << endl; >> return 1; >> } >> >> printMenu(); >> >> inFile.close(); >> >> return 0; >> } >> >> void printMenu() >> { >> cout << " ---------------------Menu--------------------" << endl << >> endl; >> cout << "Welcome to Kathy Gibson's Hardware Store!" << endl; >> cout << "Choose from the following menu options: " << endl << endl << endl >> << endl; >> cout << " 1: To see if an item is in the store " << endl; >> cout << " 2: To buy an item " endl; > > missing << > > >> cout << " 3: To check the price of an item " << endl; >> cout << " 4: To print the inventory " << endl; >> cout << " 9: To end the program " << endl; >> >> } > >
From: DrNoose on 27 Mar 2006 15:38 Hi! Yes, the headers are for later use in the program. As for main, that's the only way I've learned where to put it. I've not used VS very much and don't know all of it's finer workings! How do I open the command window? Thanks! Paul F. Johnson wrote: > DrNoose wrote: > >> I'm trying to do this thing one step at a time to make sure everything >> works right. > > Good plan. > >> The problem I'm having is that when I go to run the program, all I see >> is "Press any key to continue", I don't see my menu. It builds okay >> without any errors. > >> #include <iostream> >> #include <iomanip> >> #include <fstream> >> #include <string> >> #include <vector> > > I take it that most of these headers are for use later on in the program? > >> using namespace std; > >> void printMenu(); > > Personal preference, have main() at the end - it avoids prototyping. > >> printMenu(); > > On my machine, it prints the menu (I've removed the infile bit for obviously > reasons). > > What it could be is that you're running the program from within VisualStudio > (assuming that's what it is you're using). That has a very nasty habit of > not showing what is going on. Try opening a command window and running the > program from within there. > > TTFN > > Paul
|
Next
|
Last
Pages: 1 2 3 Prev: Inline asm C code problem Next: sorting the names in the ascending order |