Thread: tictactoe symbol entering problem

  1. #1
    Registered User
    Join Date
    Feb 2006
    Location
    Philadelphia, PA
    Posts
    27

    tictactoe symbol entering problem

    Hi,

    I'm writing a code for tictactoe game, my code compiles, but when I try to input the values, it doesn't work properly.

    here's function for the input.

    Code:
    void enter_symbol(char ttt[][3], int player)
    {
            int row, col;
            while(1)
            {
                    printf("Player 1 plese specify where you would like to enter a symbol, and enter it\n");
                    scanf("%d", &row);
                    scanf("%d", &col);
                    if(ttt[row][col] ==' ')
                    {   
                            ttt[row][col]='x';
                            break;
                    }
                    else
                      printf("Position you specified is already taken, try again\n");
            }
     
            while(1)
            {
                    printf("Player 2 plese speficy where you would like to enter a symbol, and enter it\n");
                    scanf("%d", &row);
                    scanf("%d", &col);
                    if(ttt[row][col] ==' ')
                    {
                            ttt[row][col]='o';
                            break;
                    }
                    else
                      printf("Position you specified is already taken, try again\n");
            }
    }

    Here's what i get when i run it

    Code:
    Player 1 plese specify where you would like to enter a symbol, and enter it
    11
    12
    Position you specified is already taken, try again
    Player 1 plese specify where you would like to enter a symbol, and enter it
    13^H^H
    hulk:~/Lab07>tictactoe
    Player 1 plese specify where you would like to enter a symbol, and enter it
    11
    12
    Position you specified is already taken, try again
    Player 1 plese specify where you would like to enter a symbol, and enter it
    12
    13
    Position you specified is already taken, try again
    Player 1 plese specify where you would like to enter a symbol, and enter it
    can you see what's wrong with it? I can't.

    Thanks
    Last edited by ademkiv; 03-21-2006 at 11:26 AM.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Why are you entering twelve and thirteen, when the only space allowed is zero through two?


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stale Symbol File Problem
    By chiefmonkey in forum C++ Programming
    Replies: 1
    Last Post: 06-16-2009, 03:24 PM
  2. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 05:20 AM
  3. whats wrong with this
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 02-07-2002, 03:40 PM
  4. Greenhand want help!
    By leereg in forum C Programming
    Replies: 6
    Last Post: 01-29-2002, 06:04 AM
  5. Compiler errors
    By BellosX in forum C Programming
    Replies: 2
    Last Post: 09-21-2001, 03:24 AM