0
#include <stdio.h>
#include <stdlib.h>
#define rsize 3
#define csize 3

int
main()
{
    char tictac[rsize][csize];
    int a, b;

    printf("WELCOME TO TIC TAC TOE \n");

    for(a = 0; a < rsize; a++)
    {
        for(b = 0; b < csize; b++)
        {
            printf("Enter X or O: ");
            scanf(" %c", &tictac[a][b]);
        }
    }
    for(a = 0; a < rsize; a++)
    {
        if (tictac[a][0] == tictac[a][1] && tictac[a][1] == tictac[a][2]);
        {
            printf("Row %d has all %c's \n", a, tictac[a][0]);
        }
        if (tictac[0][a] == tictac[1][a] && tictac[1][a] == tictac[2][a]);
        {
            printf("Column %d has all %c's \n", a, tictac[0][a]);
        }
    }

    system("pause");
    return(0);
}

It's supposed to be a 3x3 tictac toe game but it doesn't seem to be working. The problem is the if statement I'm not sure why it doesn't work. Come someone help me out and point out my problem?

1
  • It compiles very well on my system(Fedora64bit).Only problem is when i copied the code. There is a trailling semicolons at the end of file. Commented Mar 11, 2011 at 6:27

2 Answers 2

5

You have extra semicolons in the middle of the if statements that cause them to be empty. So your code is effectively

if (...) {
   /* do nothing */
}
{
    printf(...
}

and the printfs are always executed. Get rid of the ';' between the ')' and the '{'

Sign up to request clarification or add additional context in comments.

1 Comment

I can't believe I did that! Thanks!
1

After IF( condition), you have placed a semicolon(;). Remove that.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.