Infinite Looping D: HELP!

Ok, so I am writing a tic-tac-toe program. Whenever I choose a spot on the board (ex: 1) then it does it correctly... but , if I put a letter or multiple numbers then the program loops and breaks. Help? Here's my code that's not working when I put the incorrect variable in (btw: "spot" is an int):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
void playerbeg()
{
     cout << "What spot would you like? (0 to quit) : ";
     cin >> spot;

     if(spot == 0)
     {scoresview();
     
     if(playerxscore > playeroscore)
     {cout << "You beat the computer! Congrats!" << endl;
     if(playerxscore > lowhighscore){highscores();}
     if(playerxscore <= lowhighscore){cout << "However, You did not beat the lowest high score...sorry.";}
     cout << "Would you like to go back to main? (1 for yes ; 0 for no) : ";
     cin >> answer;}
     
     if(playeroscore > playerxscore)
     {cout << "Sorry computer won." << endl;
     cout << "Would you like to go back to main? (1 for yes ; 0 to exit) : ";
     cin >> answer;}
     
     if(answer == 1)
     {startscreen();}
     
     if(answer == 0)
     {exit(0);}
     
     
}
     
     if(spot== 1, 2, 3, 4, 5, 6, 7, 8, 9){
            if(set[spot-1]=='O'){
                    cout << "Spot taken. Choose another.";
                    playerbeg();
            }
            if(set[spot-1]=='X'){
                   cout << "Spot taken. Choose another.";
                   playerbeg();
            }
            if(set[spot-1]!='X' && set[spot-1]!='O')
            {
                 set[spot-1]='X';
                 checkwinners();
                 randoms();
            }
                                                
     }     

}
Last edited on
well idk if this will help or not but i am having a hard time trying to find matching curly braces. On line 7 you open, but you don't close. Anyway, let me know if that solves anything.
Last edited on
Topic archived. No new replies allowed.