Need help with functions

Started by
2 comments, last by jflanglois 19 years, 4 months ago
How can I implement this function New Game() In case 1: #include <iostream> #include <string> #include <stdlib.h> #include <conio.h> using namespace std; int choice=0; void NewGame(); void GameMenu(); bool playingGame=true; bool answer1=true; void NewGame() { cout<<"\t\t _|_|_ cout<<"\t\t _|_|_ cout<<"\t\t | | cout<<"\t\t } void GameMenu() { cout<<"\t\t **************************\n"; cout<<"\t\t * *\n"; cout<<"\t\t * *\n"; cout<<"\t\t * 1. New Game *\n"; cout<<"\t\t * 2. High Score *\n"; cout<<"\t\t * 3. Options *\n"; cout<<"\t\t * 4. Exit *\n"; cout<<"\t\t * *\n"; cout<<"\t\t *Created By C_Programmer!*\n"; cout<<"\t\t **************************\n"; } int main() { while(playingGame) { GameMenu(); cout<<"Choose from the Menu: "; cin>>choice; switch(choice) { case 1: cout<<"Starting New Game\n"; break; case 2: cout<<"High Score Works\n"; break; case 3: cout<<"Options Works\n"; break; case 4: playingGame=false; cout<<"Exiting Works\n"; break; } } system("PAUSE"); return 0; } Thank You!!!!
Computers are worlds of Exploration?
Advertisement
Just call 'NewGame()' in the 'case 1:' expression:
#include <iostream>#include <string>#include <stdlib.h>#include <conio.h>using namespace std;int choice=0;void NewGame();void GameMenu();bool playingGame=true;bool answer1=true;void NewGame(){// I added quotes and 'endl' belowcout<<"\t\t _|_|_ " << endl;cout<<"\t\t _|_|_ " << endl;cout<<"\t\t | | " << endl;cout<<"\t\t " << endl;} void GameMenu(){cout<<"\t\t **************************\n";cout<<"\t\t * *\n";cout<<"\t\t * *\n";cout<<"\t\t * 1. New Game *\n";cout<<"\t\t * 2. High Score *\n";cout<<"\t\t * 3. Options *\n";cout<<"\t\t * 4. Exit *\n";cout<<"\t\t * *\n";cout<<"\t\t *Created By C_Programmer!*\n";cout<<"\t\t **************************\n";}int main(){while(playingGame){GameMenu();cout<<"Choose from the Menu: ";cin>>choice;switch(choice){case 1: cout<<"Starting New Game\n";// call to 'NewGame()' functionNewGame();break;case 2:cout<<"High Score Works\n";break;case 3:cout<<"Options Works\n";break;case 4: playingGame=false;cout<<"Exiting Works\n";break;} }system("PAUSE");return 0;}


Good luck,
Pat.
Does not work

This is the error I keep getting


missing terminating " character
Computers are worlds of Exploration?
Make sure you use darookie's updated NewGame function. You had forgotten to put quotes and endl's (or \n);

This topic is closed to new replies.

Advertisement