Errors:
1>main.cpp(9): error C2143: syntax error : missing ')' before 'constant'
1>main.cpp(9): error C2143: syntax error : missing ';' before 'constant'
1>main.cpp(9): error C2059: syntax error : ')'
1>main.cpp(63): error C2660: 'checker' : function does not take 9 arguments
1>main.cpp(71): error C2143: syntax error : missing ')' before 'constant'
1>main.cpp(71): error C2143: syntax error : missing ';' before 'constant'
1>main.cpp(71): error C2059: syntax error : ')'
1>main.cpp(72): error C2143: syntax error : missing ';' before '{'
1>main.cpp(72): error C2447: '{' : missing function header (old-style formal list?)

Relevant code:

//line 9:
bool checker(string 11, string 12, string 13, string 21, string 22, string 23, string 31, string 32, string 33);

// lines 71 and 72:
bool checker(string 11, string 12, string 13, string 21, string 22, string 23, string 31, string 32, string 33)
{

// line 63:
if(checker(board [0] [0], board [1] [0], board [2] [0], board [0] [1], board [1] [1], board [2] [1], board [0] [2], board [1] [2], board [2] [2]) == true)

// Also relevant:
string board [3] [3];

bool checker(string 11, string 12, string 13, string 21, string 22, string 23, string 31, string 32, string 33);

Your problem is rather simple to fix. I don't know exaclty what are those string 11, more speciffic the 11 part means, but, if you want to define a variable only as it's name ints, like numbers, you can't. for example you have here string 11. The compiler gives you errors saying that you can't define a variable with the name 11, because the 11 is a number, from whithin the program. It's like you're difining that 1 should be 2, if you get my point. This is easilly solved by this:

bool checker(string a11, string a12, string a13, string a21, string a22, string a23, string a31, string a32, string a33){
        return true; // I have put something before the ints, like a11 instead of just 11.
        //do stuff;
    }

If you have further questions just post them here.

I do not, however, see how this parameter scheme is better than passing the array as whole by reference to the checker.

Thanks luciandrew that fixed all of my problems.

I do not, however, see how this parameter scheme is better than passing the array as whole by reference to the checker.

Sorry I'm relatively new, I didn't fully undrstand this. What I'm getting is that just remove the bool checker and add it right in main.

Example of array passing:

#include <iostream>

using namespace std;

char value(char t[3][3]) {
    return t[1][1];
}

int main()
{
    char  board[3][3] = {{'x', ' ', ' '},
                      {' ', 'x', ' '},
                      {'x', ' ', 'o'}
                    };
    cout << value(board) << endl;
    return 0;
}

Oh, yeah that does make sense.

I started to create an AI after I finished the game where people play against each other, unfortunately there are errors.
Errors:
1> ai.cpp
1>c:\users\will\documents\visual studio 2010\projects\tic\tic\ai.h(9): error C2061: syntax error : identifier 'string'
1>ai.cpp(11): error C2065: 'string' : undeclared identifier
1>ai.cpp(11): error C2146: syntax error : missing ')' before identifier 'a'
1>ai.cpp(11): error C2761: 'void ai::read(void)' : member function redeclaration not allowed
1>ai.cpp(11): error C2059: syntax error : ')'
1>ai.cpp(12): error C2143: syntax error : missing ';' before '{'
1>ai.cpp(12): error C2447: '{' : missing function header (old-style formal list?)
1> main.cpp
1>c:\users\will\documents\visual studio 2010\projects\tic\tic\ai.h(9): error C2061: syntax error : identifier 'string'
1>main.cpp(104): error C2660: 'ai::read' : function does not take 1 arguments
Code:

//ai.h line 9
public:
void ai::read(string a [] []);

//ai.cpp lines 11 and 12
void ai::read(string a [] [])
{

//ai.cpp line 104
ai myAI;
myAI.read(board);

Edited 4 Years Ago by Albino

To make your code more readable, look at how pyTony wrote the subscripte value. I'm all for using SPACEs, but too many also make code hard to read.

Is the difference between this: examp[][] and this: examp [] [] that large.
`

When you are asking other people that know how to program to read your code the difference is large enough.

Professionals have learned proper formatting techniques and when someone messes with that, it does make it harder to follow the code.

Why do you feel your way is better?

Edited 4 Years Ago by WaltP

I never said that it was any better, it's just how I like to do it. Would you like to contribute to the current problem?

If you need second opinion, I think separating subscript from array with space make me also grawl ;) I do understand that your consideration is more "Get that d*mn code to work!".

Sorry, if we sound pedantic, but old coders just want you to not catch bad habits which will hurt you in future. Latest when you start working in team environment. We have experience with badly indented code, with only variable names like a1, a2, x, y, i, l. And after you try to figure it out, you are sure to pay attention to your formatting and varible names. It really is very important, trust us.

I never didn't trust you, I am new to C++ after all. One of you moderators could edit my above code to make it more legible.

Like you said, I would like the code to work.

Edited 4 Years Ago by Albino

This article has been dead for over six months. Start a new discussion instead.