Please help, im new to C++ and im getting errors

This is a discussion on Please help, im new to C++ and im getting errors within the C++ Programming forums, part of the General Programming Boards category; okay i need some help with my program i keep geting errors everytime i fix something...i have many questions.. please ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    5

    Exclamation Please help, im new to C++ and im getting errors

    okay i need some help with my program i keep geting errors everytime i fix something...i have many questions.. please dont just tell me what to fix, please explain it as well. but be aware im extreamely new to C++ so explain them ina way a newbie would understand =)

    after i open it it shows intro screen then asks the player there name, i type in a name, and then instead of switching over and going on through the game.... the intro screen pops right back up asking there name again....

    please help?!?

    =(

    here's my code... (I UPDATED IT)
    Code:
    #include <iostream>
    #include <string>
    #include <cstdlib>
    #include <ctime>
    
    using namespace std;
    
    
    int Diceroll();
    int Introscreen();
    void Tryagain();
    void Win();
    		int Totalbears;
    		int Dicenumber;
    		int Useranswer;
    		int Totalcorrect;
    		string PLAYAGAIN;
    		string NAME;
    		bool PLAY = true;
    
    
    int main()
    {
    		srand((unsigned)time(NULL));
    		
    		string PLAYAGAIN = "yes";
    
    		while (PLAYAGAIN == "yes")
    		
    		Introscreen();
    
    		while(PLAY)
    		{
    
    				Totalcorrect = 0;
    
    				for (int iCOUNT=1; iCOUNT<11; iCOUNT++)
    				{
    
    						if (Useranswer==3)
    						{
    								Win();
    						}
    
    						Diceroll();
    
    						cout<<"How many polar bears do you see around the ice holes?"<<endl;
    						cin>>Useranswer;
    
    						if (Useranswer == Totalbears)
    						{ 
    								cout<<"Correct! =D"<<endl;
    								Totalcorrect++;
    						}
    						else
    						{
    								cout<<"Incorrect! The right answer was: "<<Totalbears<<endl;
    						}
    						system("pause");
    
    						Tryagain();
    				}
    		}		
    return 0;
    		}
    
    
    void LOSE (string NAME)
    
    {
    		//the losing screen
    		cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<< endl;
    		cout<<"!                                      !"<<endl;
    		cout<<"!        Sorry,                        !"<<endl;
    		cout<<"!                 You Lose!            !"<<endl;
    		cout<<"!                                      !"<<endl;
    		cout<<"!                                      !"<<endl;
    		cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl<<endl;
    		cout<<endl;
    
    		cout<<"SORRY "<<NAME<< " YOU LOST"<<endl<<endl;
    		cout<<"BETTER LUCK NEXT TIME"<<endl;
    }
    		//the intoduction screen
    int Introscreen()
    {
    		cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl;
    		cout<<"!                                      !"<<endl;
    		cout<<"!                                      !"<<endl;
    		cout<<"!             Ice and Dice             !"<<endl;
    		cout<<"!                                      !"<<endl;
    		cout<<"!                                      !"<<endl;
    		cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl<<endl;
    		cout<<endl;
    
    		cout<<"Game details:"<<endl;
    		cout<<"The name is in the game, and the game is in the name."<<endl;
    		cout<<"and the name of the game is Polar Bears Around An Ice Hole."<<endl;
    		cout<<"Some people call this Petals Around A Rose."<<endl<<endl;
    		cout<<endl;
    		cout<<"Wish to play? Please enter your name here:"<<endl;
    		cin>>NAME;
    return 0;
    }
    
    int Diceroll()
    {
    		Totalbears = 0;
    
    		for (int numRoll = 1; numRoll<4; numRoll++)
    		{
    				Dicenumber=1+rand()%6;
    
    				switch(Dicenumber)
    				{
    						case 1:
    						{
    								cout<<"*******"<<endl;
    								cout<<"*     *"<<endl;
    								cout<<"*  0  *"<<endl;
    								cout<<"*     *"<<endl;
    								cout<<"*******"<<endl;
    								Totalbears = Totalbears+0;
    								break;
    						}
    
    						case 2:
    						{
    								cout<<"********"<<endl;
    								cout<<"*    0 *"<<endl;
    								cout<<"*      *"<<endl;
    								cout<<"* 0    *"<<endl;
    								cout<<"********"<<endl;
    								Totalbears = Totalbears+0;
    								break;
    						}
    
    						case 3:
    						{
    								cout<<"*******"<<endl;
    								cout<<"*  0  *"<<endl;
    								cout<<"*  0  *"<<endl;
    								cout<<"*  O  *"<<endl;
    								cout<<"*******"<<endl;
    								Totalbears = Totalbears+2;
    								break;
    						}
    
    						case 4:
    						{
    								cout<<"*********"<<endl;
    								cout<<"*  0 0  *"<<endl;
    								cout<<"*       *"<<endl;
    								cout<<"*  0 0  *"<<endl;
    								cout<<"*********"<<endl;
    								Totalbears = Totalbears+0;
    								break;
    						}
    
    						case 5:
    						{
    								cout<<"*********"<<endl;
    								cout<<"* O   O *"<<endl;
    								cout<<"*   O   *"<<endl;
    								cout<<"* O   O *"<<endl;
    								cout<<"*********"<<endl;
    								Totalbears = Totalbears+4;
    								break;
    						}
    
    						case 6:
    						{
    								cout<<"********"<<endl;
    								cout<<"* O  O *"<<endl;
    								cout<<"* O  O *"<<endl;
    								cout<<"* O  O *"<<endl;
    								cout<<"********"<<endl;
    								Totalbears = Totalbears+0;
    								break;
    						}
    
    						default:
    						break;
    				}//end of switch
    		}
    		return 0;
    }
    void Win ()
    {
    		cout<<"Congratulations, "<<NAME<<", You have won! =D"<<endl;
    }
    void Tryagain()
    {
    		cout<<"Want to play again? (yes or no)"<<endl;
    		cin>>PLAYAGAIN;
    
    		if (PLAYAGAIN == "no")
    		{
    		PLAY = false;
    		cout<<"Bye"<<endl;
    		}
    		if (PLAYAGAIN == "yes")
    		{
    		PLAY = true;
    		cout<<"Okay!"<<endl;
    		}
    }
    Last edited by Tiffany_DD; 05-01-2009 at 10:33 PM.

  2. #2
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    void Tryagain();

    should be

    void Tryagain()
    {
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    5
    okay i fixed that, stil geting errors
    sayin
    error C2143: syntax error : missing ';' before '<<'

  4. #4
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    well first of all it would be a great help if you indent your code,
    and second, your program is just fine , but you missed some {s ( actually 3 of them i think!,) and you had couple of ';' ! for that just check the two program to see what your problems were
    Code:
    #include <iostream>
    #include <string>
    #include <cstdlib>
    #include <ctime>
    
    using namespace std;
    
    
    int Diceroll();
    int Introscreen();
    void Tryagain();
    void Win();
    
            int Totalbears;
            int Dicenumber;
            int Useranswer;
            int Totalcorrect;
            string PLAYAGAIN;
            string NAME;
            bool PLAY = true;
    
    
    int main()
    {
            srand((unsigned)time(NULL));
    
            string PLAYAGAIN = "yes";
    
            while (PLAYAGAIN == "yes")
           {
                    Introscreen();
    
            while(PLAY)
            {
    
                    Totalcorrect = 0;
    
                    for (int iCOUNT=1; iCOUNT<11; iCOUNT++)
                    {
    
                            if (Useranswer==3)
                            {
                                    Win();
                            }
    
                            Diceroll();
    
                            cout<<"How many polar bears do you see around the ice holes?"<<endl;
                            cin>>Useranswer;
    
                            if (Useranswer == Totalbears)
                            {
                                    cout<<"Correct! =D"<<endl;
                                    Totalcorrect++;
                            }
                            else
                            {
                                    cout<<"Incorrect! The right answer was: "<<Totalbears<<endl;
                            }
                            //system("pause");
    
                            Tryagain();
                    }
    
            }
    
            }
      return 0;
            }
    
    
    void LOSE (string NAME)
    {
            //the losing screen
            cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl;
            cout<<"!                                      !"<<endl;
            cout<<"!        Sorry,                        !"<<endl;
            cout<<"!                 You Lose!            !"<<endl;
            cout<<"!                                      !"<<endl;
            cout<<"!                                      !"<<endl;
            cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl<<endl;
            cout<<endl;
    
            cout<<"SORRY "<<NAME<< " YOU LOST"<<endl<<endl;
            cout<<"BETTER LUCK NEXT TIME"<<endl;
    }
            //the intoduction screen
    int Introscreen()
    {
            cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<< endl;
            cout<<"!                                      !"<<endl;
            cout<<"!                                      !"<<endl;
            cout<<"!             Ice and Dice             !"<<endl;
            cout<<"!                                      !"<<endl;
            cout<<"!                                      !"<<endl;
            cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl<<endl;
            cout<<endl;
    
            cout<<"Game details:"<<endl;
            cout<<"The name is in the game, and the game is in the name."<<endl;
            cout<<"and the name of the game is Polar Bears Around An Ice Hole."<<endl;
            cout<<"Some people call this Petals Around A Rose."<<endl<<endl;
            cout<<endl;
            cout<<"Wish to play? Please enter your name here:"<<endl;
            cin>>NAME;
    
    return 0;
    }
    
    
    
    
    int Diceroll()
    {
            Totalbears = 0;
    
            for (int numRoll = 1; numRoll<4; numRoll++)
            {
                    Dicenumber=1+rand()%6;
    
                    switch(Dicenumber)
                    {
                            case 1:
                            {
                                    cout<<"*******"<<endl;
                                    cout<<"*     *"<<endl;
                                    cout<<"*  0  *"<<endl;
                                    cout<<"*     *"<<endl;
                                    cout<<"*******"<<endl;
                                    Totalbears = Totalbears+0;
                                    break;
                            }
    
                            case 2:
                            {
                                    cout<<"********"<<endl;
                                    cout<<"*    0 *"<<endl;
                                    cout<<"*      *"<<endl;
                                    cout<<"* 0    *"<<endl;
                                    cout<<"********"<<endl;
                                    Totalbears = Totalbears+0;
                                    break;
                            }
    
                            case 3:
                            {
                                    cout<<"*******"<<endl;
                                    cout<<"*  0  *"<<endl;
                                    cout<<"*  0  *"<<endl;
                                    cout<<"*  O  *"<<endl;
                                    cout<<"*******"<<endl;
                                    Totalbears = Totalbears+2;
                                    break;
                            }
    
                            case 4:
                            {
                                    cout<<"*********"<<endl;
                                    cout<<"*  0 0  *"<<endl;
                                    cout<<"*       *"<<endl;
                                    cout<<"*  0 0  *"<<endl;
                                    cout<<"*********"<<endl;
                                    Totalbears = Totalbears+0;
                                    break;
                            }
    
                            case 5:
                            {
                                    cout<<"*********"<<endl;
                                    cout<<"* O   O *"<<endl;
                                    cout<<"*   O   *"<<endl;
                                    cout<<"* O   O *"<<endl;
                                    cout<<"*********"<<endl;
                                    Totalbears = Totalbears+4;
                                    break;
                            }
    
                            case 6:
                            {
                                    cout<<"********"<<endl;
                                    cout<<"* O  O *"<<endl;
                                    cout<<"* O  O *"<<endl;
                                    cout<<"* O  O *"<<endl;
                                    cout<<"********"<<endl;
                                    Totalbears = Totalbears+0;
                                    break;
                            }
    
                            default:
                            break;
    
                    }//end of switch
            }
            return 0;
    }
    
    void Win ()
    {
            cout<<"Congratulations, "<<NAME<<", You have won! =D"<<endl;
    }
    
    void Tryagain()
    {
            cout<<"Want to play again? (yes or no)"<<endl;
            cin>>PLAYAGAIN;
    
            if (PLAYAGAIN == "no")
            {
                    PLAY = false;
                    cout<<"Bye"<<endl;
            }
            if (PLAYAGAIN == "yes")
            {
                    PLAY = true;
                    cout<<"Okay!"<<endl;
            }
     }
    Last edited by Masterx; 05-01-2009 at 10:16 PM.
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  5. #5
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    more details :
    take a good look here
    your first mistak !: line 199 cout;<<"Want to play again? (yes or no)";<<endl;
    your second mistake :
    look closely
    you wrote :
    Code:
    void Tryagain();
    
    cout<<"Want to play again? (yes or no)"<<endl;
    cin>>PLAYAGAIN;
    
    if (PLAYAGAIN == "no")
    
    PLAY = false;
    cout<<"Bye"<<endl;
    
    if (PLAYAGAIN == "yes")
    
    PLAY = true;
    cout<<"Okay!"<<endl;
    }
    while you missed the starting "{" and also you put a semicolon ";" before '{' which is wrong
    the correct one is
    Code:
    void Tryagain()
    {
            cout<<"Want to play again? (yes or no)"<<endl;
            cin>>PLAYAGAIN;
    
            if (PLAYAGAIN == "no")
            {
            PLAY = false;
            cout<<"Bye"<<endl;
            }
            if (PLAYAGAIN == "yes")
            {
            PLAY = true;
            cout<<"Okay!"<<endl;
            }
     }
    also i noticed that you missed to type "return 0" at the end of your main function!
    and besides that! i saw you wrote:
    Code:
    if (Useranswer == Totalbears)
                           
                                    cout<<"Correct! =D"<<endl;
                                    Totalcorrect++;
                           
                            else
                            
                                    cout<<"Incorrect! The right answer was: "<<Totalbears<<endl;
    do you actually mean if the answer eqauls to totalbears, totalcorrect should increase? if so you must put them in braces , to avoid logic errors! if not remove that part.


    which as you see i changed it to
    Code:
    if (Useranswer == Totalbears)
                            {
                                    cout<<"Correct! =D"<<endl;
                                    Totalcorrect++;
                            }
                            else
                            {
                                    cout<<"Incorrect! The right answer was: "<<Totalbears<<endl;
                            }
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    5
    : error C2143: syntax error : missing ';' before '<<'

    i did what u said spaced it and everything andim stil geting that error

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    5
    okay i fixed everything now it has yet another error

    cpp(103) : error C4716: 'Introscreen' : must return a value
    Last edited by Tiffany_DD; 05-01-2009 at 10:03 PM.

  8. #8
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    Quote Originally Posted by Tiffany_DD View Post
    : error C2143: syntax error : missing ';' before '<<'

    i did what u said spaced it and everything andim stil geting that error
    did you use my code ? my code compiles just fine! no comiple time error! but your program has definitely couple of logic errors, the one i just noticed is
    at line 29
    Code:
     while (PLAYAGAIN == "yes")
    you must place the rest of the codes inside a brace! if you dont do that! you will always get that intro screen!
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  9. #9
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    Quote Originally Posted by Tiffany_DD View Post
    okay i fixed everything now it has yet another error

    cpp(103) : error C4716: 'Introscreen' : must return a value
    yup, you missed the return 0;
    Code:
    int Introscreen()
    {
            cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<< endl;
            cout<<"!                                      !"<<endl;
            cout<<"!                                      !"<<endl;
            cout<<"!             Ice and Dice             !"<<endl;
            cout<<"!                                      !"<<endl;
            cout<<"!                                      !"<<endl;
            cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl<<endl;
            cout<<endl;
    
            cout<<"Game details:"<<endl;
            cout<<"The name is in the game, and the game is in the name."<<endl;
            cout<<"and the name of the game is Polar Bears Around An Ice Hole."<<endl;
            cout<<"Some people call this Petals Around A Rose."<<endl<<endl;
            cout<<endl;
            cout<<"Wish to play? Please enter your name here:"<<endl;
            cin>>NAME;
    
    return 0;
    }
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  10. #10
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    i corrected the logic error i noticed in main! i gotta go , dont know if there is any left!
    Code:
    #include <iostream>
    #include <string>
    #include <cstdlib>
    #include <ctime>
    
    using namespace std;
    
    
    int Diceroll();
    int Introscreen();
    void Tryagain();
    void Win();
    
            int Totalbears;
            int Dicenumber;
            int Useranswer;
            int Totalcorrect;
            string PLAYAGAIN;
            string NAME;
            bool PLAY = true;
    
    
    int main()
    {
            srand((unsigned)time(NULL));
    
            string PLAYAGAIN = "yes";
    
            while (PLAY)
           {
                    Introscreen();
    
            while(PLAY)
            {
    
                    Totalcorrect = 0;
    
                    for (int iCOUNT=1; iCOUNT<11; iCOUNT++)
                    {
    
                            if (Useranswer==3)
                            {
                                    Win();
                            }
    
                            Diceroll();
    
                            cout<<"How many polar bears do you see around the ice holes?"<<endl;
                            cin>>Useranswer;
    
                            if (Useranswer == Totalbears)
                            {
                                    cout<<"Correct! =D"<<endl;
                                    Totalcorrect++;
                            }
                            else
                            {
                                    cout<<"Incorrect! The right answer was: "<<Totalbears<<endl;
                            }
                            //system("pause");
    
                            Tryagain();
                            if ( PLAY == false )
                                break;
                    }
    
            }
    
            }
      return 0;
            }
    
    
    void LOSE (string NAME)
    {
            //the losing screen
            cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl;
            cout<<"!                                      !"<<endl;
            cout<<"!        Sorry,                        !"<<endl;
            cout<<"!                 You Lose!            !"<<endl;
            cout<<"!                                      !"<<endl;
            cout<<"!                                      !"<<endl;
            cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl<<endl;
            cout<<endl;
    
            cout<<"SORRY "<<NAME<< " YOU LOST"<<endl<<endl;
            cout<<"BETTER LUCK NEXT TIME"<<endl;
    }
            //the intoduction screen
    int Introscreen()
    {
            cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<< endl;
            cout<<"!                                      !"<<endl;
            cout<<"!                                      !"<<endl;
            cout<<"!             Ice and Dice             !"<<endl;
            cout<<"!                                      !"<<endl;
            cout<<"!                                      !"<<endl;
            cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl<<endl;
            cout<<endl;
    
            cout<<"Game details:"<<endl;
            cout<<"The name is in the game, and the game is in the name."<<endl;
            cout<<"and the name of the game is Polar Bears Around An Ice Hole."<<endl;
            cout<<"Some people call this Petals Around A Rose."<<endl<<endl;
            cout<<endl;
            cout<<"Wish to play? Please enter your name here:"<<endl;
            cin>>NAME;
    
    return 0;
    }
    
    
    
    
    int Diceroll()
    {
            Totalbears = 0;
    
            for (int numRoll = 1; numRoll<4; numRoll++)
            {
                    Dicenumber=1+rand()%6;
    
                    switch(Dicenumber)
                    {
                            case 1:
                            {
                                    cout<<"*******"<<endl;
                                    cout<<"*     *"<<endl;
                                    cout<<"*  0  *"<<endl;
                                    cout<<"*     *"<<endl;
                                    cout<<"*******"<<endl;
                                    Totalbears = Totalbears+0;
                                    break;
                            }
    
                            case 2:
                            {
                                    cout<<"********"<<endl;
                                    cout<<"*    0 *"<<endl;
                                    cout<<"*      *"<<endl;
                                    cout<<"* 0    *"<<endl;
                                    cout<<"********"<<endl;
                                    Totalbears = Totalbears+0;
                                    break;
                            }
    
                            case 3:
                            {
                                    cout<<"*******"<<endl;
                                    cout<<"*  0  *"<<endl;
                                    cout<<"*  0  *"<<endl;
                                    cout<<"*  O  *"<<endl;
                                    cout<<"*******"<<endl;
                                    Totalbears = Totalbears+2;
                                    break;
                            }
    
                            case 4:
                            {
                                    cout<<"*********"<<endl;
                                    cout<<"*  0 0  *"<<endl;
                                    cout<<"*       *"<<endl;
                                    cout<<"*  0 0  *"<<endl;
                                    cout<<"*********"<<endl;
                                    Totalbears = Totalbears+0;
                                    break;
                            }
    
                            case 5:
                            {
                                    cout<<"*********"<<endl;
                                    cout<<"* O   O *"<<endl;
                                    cout<<"*   O   *"<<endl;
                                    cout<<"* O   O *"<<endl;
                                    cout<<"*********"<<endl;
                                    Totalbears = Totalbears+4;
                                    break;
                            }
    
                            case 6:
                            {
                                    cout<<"********"<<endl;
                                    cout<<"* O  O *"<<endl;
                                    cout<<"* O  O *"<<endl;
                                    cout<<"* O  O *"<<endl;
                                    cout<<"********"<<endl;
                                    Totalbears = Totalbears+0;
                                    break;
                            }
    
                            default:
                            break;
    
                    }//end of switch
            }
            return 0;
    }
    
    void Win ()
    {
            cout<<"Congratulations, "<<NAME<<", You have won! =D"<<endl;
    }
    
    void Tryagain()
    {
            cout<<"Want to play again? (yes or no)"<<endl;
            cin>>PLAYAGAIN;
    
            if (PLAYAGAIN == "no")
            {
                    PLAY = false;
                    cout<<"Bye"<<endl;
            }
            if (PLAYAGAIN == "yes")
            {
                    PLAY = true;
                    cout<<"Okay!"<<endl;
            }
     }
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  11. #11
    Registered User
    Join Date
    May 2009
    Posts
    5
    well.....good news.....i got the program to open....

    really bad news....
    when it opends it shows intro screen and asks the person there name... after i type in a name and hit enter the intro screen pops up again.... it doesnt move on to the next thing

    any ideahs?

  12. #12
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    Quote Originally Posted by Tiffany_DD View Post
    well.....good news.....i got the program to open....

    really bad news....
    when it opends it shows intro screen and asks the person there name... after i type in a name and hit enter the intro screen pops up again.... it doesnt move on to the next thing

    any ideahs?
    i believe i told you that. here #8
    at line 29


    Code:
     while (PLAYAGAIN == "yes")
    you must place the rest of the codes inside a brace! if you dont do that! you will always get that intro screen!
    why dont you use my revised code! ? i told you how to get rid of that bug! and i myself corrected the program!(as much as i could, dont know about your progs other logic errors,just test your prog yourself) just copy and past the last code i posted! to be more precise i mean this post #10 .
    this should do it ! please before reading posts hastily pay a careful attention to them. thats all , just observe the code i postet , think about it , if you have any problem afterwards , just post , im sure the site professionals will definitely help you ,and by the way it is good to verify my sayings! ( after all im just a newbie too)
    Last edited by Masterx; 05-02-2009 at 09:50 AM.
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21