Errors running tic tac toe game found on the internet.

This is a discussion on Errors running tic tac toe game found on the internet. within the C Programming forums, part of the General Programming Boards category; Hello everyone, I just found this tic tac toe game online and I am trying to run it but I ...

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    12

    Errors running tic tac toe game found on the internet.

    Hello everyone, I just found this tic tac toe game online and I am trying to run it but I get 7 errors and 15 warnings on visual express.
    Here is my code...
    Code:
    #include<stdio.h>
    #include<conio.h>
    
    
    void Board();
    void PlayerX();
    void PlayerO();
    void Player_win();
    void check();
    int win=0,wrong_X=0,wrong_O=0,chk=0;
    
    
    char name_X[30];
    char name_O[30];
    int pos_for_X[3][3];
    int pos_for_O[3][3];
    int pos_marked[3][3];
    
    
    void main()
    {
        int i,ch,j;
        char ans;
    /*    clrscr();
        printf("\n\t\t\t\tTIC TAC TOE");
        printf("\n\t\t\t\t");
        for(i=1;i<=11;i++)
        {
            delay(1000);
            printf("*");
        }*/
        do
        {
            clrscr();
            printf("\n\t\t\t\tTIC TAC TOE");
            printf("\n\t\t\t\t");
            for(i=1;i<=11;i++)
            {
                delay(1000);
                printf("*");
            }
            printf("\n1.Start The Game");
            printf("\n2.Quit The Game");
            printf("\nEnter your choice(1-2) : ");
            scanf("%d",&ch);
            switch(ch)
            {
                case 1:
                    chk=0;
                    win=0;
                    for(i=1;i<=3;i++)
                    {
                        for(j=1;j<=3;j++)
                        {
                            pos_for_X[i][j]=0;
                            pos_for_O[i][j]=0;
                            pos_marked[i][j]=0;
                        }
                    }
                    printf("\n\n");
                    clrscr();
                    printf("\nEnter the name of the player playing for \'X\': ");
                    fflush(stdin);
                    gets(name_X);
                    printf("\nEnter the name of the player playing for \'O\': ");
                    fflush(stdin);
                    gets(name_O);
                    Board();
                    for(;;)
                    {
                        if(win==1)
                            break;
                        check();
                        if(chk==9)
                        {
                            printf("\n\t\t\tMATCH DRAWS!!");
                            printf("\nPress any key....");
                            break;
                        }
                        else
                            chk=0;
                        printf("\nTURN FOR %s:",name_X);
                        PlayerX();
                        do
                        {
                            if(wrong_X!=1)
                                break;
                            wrong_X=0;
                            printf("\nTURN FOR %s:",name_X);
                            PlayerX();
                        }while(wrong_X==1);
                        check();
                        if(chk==9)
                        {
                            printf("\n\t\t\tMATCH DRAWS");
                            printf("\nPress any key....");
                            break;
                        }
                        else
                            chk=0;
                        printf("\nTURN FOR %s:",name_O);
                        PlayerO();
                        do
                        {
                            if(wrong_O!=1)
                                break;
                            wrong_O=0;
                            printf("\nTURN FOR %s:",name_O);
                            PlayerO();
                        }while(wrong_O==1);
    
    
                        }
                    Board();
                    if(win!=1)
                    {
                        printf("\n\t\t\tMATCH DRAWS!!");
                        printf("\nPress any key.......");
                    }
                    getch();
                    break;
                case 2:
                    printf("\n\n\n\t\t\tThank You For Playing The Game.");
                    getch();
                    exit(1);
                    break;
            }
            printf("\nWant To Play(Y/N) ? ");
            fflush(stdin);
            scanf("%c",&ans);
        }while(ans=='y' || ans=='Y');
    }
    
    
    
    
    void Board()
    {
        int i,j;
        clrscr();
        printf("\n\t\t\t\tTIC TAC TOE BOARD");
        printf("\n\t\t\t\t*****************");
        printf("\n\n\n");
        printf("\n\t\t\t    1\t      2\t        3");
        for(i=1;i<=3;i++)
        {
            printf("\n \t\t\t _____________________________");
            printf("\n \t\t\t\t  \t   \t     ");
            printf("\n\t\t%d\t",i);
            for(j=1;j<=3;j++)
            {
    
    
                if(pos_for_X[i][j]==1)
                {
                    printf("    X");
                    printf("     ");
                }
                else if(pos_for_O[i][j]==1)
                {
                    printf("    O");
                    printf("     ");
                }
                else
                {
                    printf("          ");
                    continue;
                }
            }
            printf("\n\t\t\t\t  \t   \t     ");
        }
        printf("\n\t\t\t------------------------------");
        Player_win();
    }
    
    
    
    
    void PlayerX()
    {
        int row,col;
        if(win==1)
            return;
        printf("\nEnter the row no. : ");
        fflush(stdin);
        scanf("%d",&row);
        printf("Enter the column no. : ");
        fflush(stdin);
        scanf("%d",&col);
        if(pos_marked[row][col]==1 || row<1 || row>3 || col<1 || col>3)
        {
            printf("\nWRONG POSITION!! Press any key.....");
            wrong_X=1;
            getch();
            Board();
        }
        else
        {
            pos_for_X[row][col]=1;
            pos_marked[row][col]=1;
            Board();
        }
    }
    void PlayerO()
    {
        int row,col;
        if(win==1)
            return;
        printf("\nEnter the row no. : ");
        scanf("%d",&row);
        printf("Enter the column no. : ");
        scanf("%d",&col);
        if(pos_marked[row][col]==1 || row<1 || row>3 || col<1 || col>3)
        {
            printf("\nWRONG POSITION!! Press any key....");
            wrong_O=1;
            getch();
            Board();
        }
        else
        {
            pos_for_O[row][col]=1;
            pos_marked[row][col]=1;
            Board();
        }
    }
    void Player_win()
    {
        int i;
        for(i=1;i<=3;i++)
        {
            if(pos_for_X[i][1]==1 && pos_for_X[i][2]==1 && pos_for_X[i][3]==1)
            {
                win=1;
                printf("\n\nRESULT: %s wins!!",name_X);
                printf("\nPress any key............");
                return;
            }
        }
        for(i=1;i<=3;i++)
        {
            if(pos_for_X[1][i]==1 && pos_for_X[2][i]==1 && pos_for_X[3][i]==1)
            {
                win=1;
                printf("\n\nRESULT: %s wins!!",name_X);
                printf("\nPress any key............");
                return;
            }
        }
        if(pos_for_X[1][1]==1 && pos_for_X[2][2]==1 && pos_for_X[3][3]==1)
        {
            win=1;
            printf("\n\nRESULTL: %s wins!!",name_X);
            printf("\nPress any key......");
            return;
        }
        else if(pos_for_X[1][3]==1 && pos_for_X[2][2]==1 && 
    pos_for_X[3][1]==1)
        {
                win=1;
            printf("\n\nRESULT: %s wins!!",name_X);
                    printf("\nPress any key.....");
            return;
        }
    
    
            for(i=1;i<=3;i++)
        {
            if(pos_for_O[i][1]==1 && pos_for_O[i][2]==1 && pos_for_O[i][3]==1)
            {
                win=1;
                printf("\n\nRESULT: %s wins!!",name_O);
                            printf("\nPress any key.....");
                return;
            }
        }
        for(i=1;i<=3;i++)
        {
            if(pos_for_O[1][i]==1 && pos_for_O[2][i]==1 && pos_for_O[3][i]==1)
            {
                win=1;
                printf("\n\nRESULT: %s wins!!",name_O);
                            printf("\nPress any key.....");
                return;
            }
        }
        if(pos_for_O[1][1]==1 && pos_for_O[2][2]==1 && pos_for_O[3][3]==1)
        {
            win=1;
            printf("\n\nRESULT: %s wins!!",name_O);
            printf("\nPress any key.....");
            return;
        }
        else if(pos_for_O[1][3]==1 && pos_for_O[2][2]==1 && 
    pos_for_O[3][1]==1)
        {
                win=1;
            printf("\n\nRESULT: %s wins!!",name_O);
                    printf("\nPress any key.....");
            return;
        }
    }
    void check()
    {
        int i,j;
        for(i=1;i<=3;i++)
        {
            for(j=1;j<=3;j++)
            {
                if(pos_marked[i][j]==1)
                    chk++;
                else
                    continue;
            }
        }
    }
    My error messages are
    Error 16 error LNK2019: unresolved external symbol _clrscr
    Error 17 error LNK2019: unresolved external symbol
    Error 18 error LNK1120: 2 unresolved externals
    identifier clrscr, delay, exit, and clrscr are undefined

    The person who created the code worked fine for him/her. Does this have anything to do about installing libraries like you do in Ruby. Thanks everyone for taking the time to read this.
    Last edited by piratemonkey247; 12-29-2012 at 07:10 PM.

  2. #2
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    407
    change line one from
    Code:
    #include<stdio.h>#include<conio.h>
    to
    Code:
    #include<stdio.h>
    #include<conio.h>

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    2,554
    From c - Using conio2 with Visual Studio 2010 - Stack Overflow

    conio was deprecated and is useless in visual studio. you could try PDcurses.
    Tim S.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  4. #4
    Registered User
    Join Date
    Dec 2012
    Posts
    12
    Quote Originally Posted by stahta01 View Post
    Thank you very much stahta01 for the quick response! And Lesshardtofind, I made the changes but with no luck, thanks to stahta01 I know why.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SOS no errors, but program not running
    By sena in forum C Programming
    Replies: 5
    Last Post: 03-14-2011, 03:48 PM
  2. Need help with some errors in my game
    By Mikalio in forum C Programming
    Replies: 4
    Last Post: 12-04-2008, 02:16 PM
  3. Need help with some errors in my game
    By Mikalio in forum C Programming
    Replies: 0
    Last Post: 12-04-2008, 02:11 PM
  4. Continued issues with Winows Errors when running program
    By hpteenagewizkid in forum C Programming
    Replies: 6
    Last Post: 11-14-2006, 02:51 PM
  5. Domain Not Found Errors with WiFi?
    By UnregdRegd in forum Tech Board
    Replies: 1
    Last Post: 11-30-2003, 03:16 PM

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