Search code examples
c++tic-tac-toe

Trying to Learn C++, Tic Tac Toe program not working


I'm trying to learn C++ and I'm writing a Tic Tac Toe program. I'm really confused and it's late, but I just want to figure out what is going wrong so I can feel like I accomplished something. Any help would be great. Here's the full code not working at all. Thanks!

http://codepad.org/fuC4JxBE

These are the errors I get:

Description                                  Resource     Path           Location    
expected primary-expression before ']' token    main.cpp    /Tic Tac Toe    line 47 C/C++ Problem
expected primary-expression before ']' token    main.cpp    /Tic Tac Toe    line 56 C/C++ Problem
expected primary-expression before ']' token    main.cpp    /Tic Tac Toe    line 57 C/C++ Problem
expected primary-expression before ']' token    main.cpp    /Tic Tac Toe    line 62 C/C++ Problem

I honestly I have no idea why I'm getting these errors. I searched around to see what the error usually means but it seemed like non of the other problems were similar.


Solution

  • The compiler error tells you anything you need to know. Add a , in line 82 after char whoWon

    edit regarding your new problem: you cannot pass multidimensional arrays like that. Remove the 3 in those brackets and the numCols in the declarations/definitions. If you really need to pass the array size, you need to pass it differently, e.g. as another argument. I take that back. I guess you have to put a constant in when passing multidimensional arrays. (In the definition/declaration)