Skip to main content
gamedev.net
🔒 Locked

Simple code problem (C++)

Started by DeadBoy Jul 17, 2006 at 9:42 PM 3 replies 600+ views
Original Post
DeadBoy
DeadBoy
I am trying to make a text slot machine. But continue getting errors while trying to compile telling me that I am missing ";"'s somewhere. I continue to look but don't see them missing anywhere.(I understand I am not making the gamet the most efficient way, but I am the way that feels most comfortable to me. So please don't criticize on that, just help me fix my problem or do not comment at all)

#include <cstdlib>
#include <iostream>

using namespace std;
    
    
  
    
    bool game = true;
    bool selection = false;

    int token;
    int one;
    int two;
    int three;
    int choice;
    int x;

int main(int argc, char *argv[])
{
////////////////
     while (game == true){//while game works                
     while (selection == false){
////////////////
    cout<<"Please select the from the following."<<endl;
    cout<<"1. Begin"<<endl;
    cout<<"2. Quit"<<endl;
    cout<<"Please press enter after you make your selection."<<endl;
    cin>>choice;
    
    
/////////////////////////////////////////////////////////////////
    if(choice == 1){
              int token = 100;//you gain 100 tokens
              system("CLS");//clear screen
              selection = true;//stop using the other screen
              srand(time(NULL));//set seed for random number
              
              cout<<"Thank you for playing."<<endl;
              cout<<"Press 1 and then enter to spin the machine."<<endl;
              cout<<"Press 2 and then enter to quit the game."<<endl;
              cout<<"After you spin it will subtract 5 tokens."<<endl;
              cout<<"If you win you will gain 100 tokens!"<<endl;
              cout<<"Have fun!!!"<<endl;
              cin>>choice;
              
              system("CLS");
              if(choice == 1){
           
                 one = (rand()%11);
                 two = (rand()%11);
                 three = (rand()%11);
                 
                 
                 cout<<one<<" "<<two<<" "<<three<<" "<<endl;
                 if (one == two && one == three){
                      token + 100; 
                   }
                  
                   
                      
                      
////////////////////////////////////////////////////////////////////////
              }
     if(choice == 2){
               cout<<"Thanks for playing I hope you had fun ";
               selection = true;
               game = false;
               }
               }  
               } 
               
               
              
                        
    system("PAUSE");
    return EXIT_SUCCESS;
}

Thanks DeadBoy
Esmo2000
Esmo2000
I don't think you properly closed the braces on if(choice == 1) (the first one). Therefore, the whole program has one more open brace then closed.

Hope it helps,
J
We are what we do repeatedly. Excellence, then, is not an act, but a habit.
Zakwayda
Zakwayda
Quote:
Original post by DeadBoy
So please don't criticize on that, just help me fix my problem or do not comment at all)
Ok :-)

Your bracing is all messed up. I can't tell you exactly where the error is because I'm not sure of your intent. If your code is actually formatted as it appears in the post, then you need to reformat it with matching and/or aligned braces so that you can tell what's actually going on. Also, if you have a 'balancing' feature in your IDE, you can use it to help find the cause of problems such as these.
DeadBoy
DeadBoy
OOPs!

I apologize for wasting everyones time. I just saw my ignerant mistake
(the braces were not supposed to close yet, though that wasn't the error)

Thanks again,
DeadBoy

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.