Dec 4, 2013 at 4:16pm
beginner at c++ and im making a checkeres game but i keep getting a 'expected a statement' error on the first 2 'else's
any help will be appreciated
void Initialise(){
for(int row=0; row<3; row++)
{
if(int row=0<3)
//player 1 pieces
string player = "Player 1";
for(int col=0; col<8; col++)
{
//every other one
if(col%2==0);
//piece (owner = player1)
}else{
//empty
}
}else(rows>2&&row<5){
for(col){
all empty
}
}else if(row>4){
for(col){
if(col%2==0){
//piece (owner.p2)
}else{
empty
}
}
}
Dec 4, 2013 at 4:19pm
First of all, please use code blocks to format your code. Those are the greater-than less-than symbols under Format:
You are missing a curly brace after the if( col % 2 == 0 ) statement; also, you have a semicolon at the end of that same line.
Dec 4, 2013 at 4:19pm
Please put your code in code tags.
if(col%2==0);
If statements do not have a semi-colon here.
Dec 4, 2013 at 4:24pm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
void Initialise(){
for(int row=0; row<3; row++)
{
if(int row=0<3)
//player 1 pieces
string player = "Player 1";
for(int col=0; col<8; col++)
{
//every other one
if(col%2==0)
//piece (owner = player1)
}else{
//empty
}
}else(rows>2&&row<5){
for(col){
all empty
}
}else if(row>4){
for(col){
if(col%2==0){
//piece (owner.p2)
}else{
empty
}
}
}
|
i get rid of the semi colon and the error still remains
Last edited on Dec 4, 2013 at 4:25pm
Dec 4, 2013 at 4:29pm
You have commented out the statement after the if for some reason.
1 2
|
if(col%2==0)
//piece (owner = player1)
|
Also, why do you have empty else statements? Nor do your else statements follow the if statement (which they must do).
Last edited on Dec 4, 2013 at 4:30pm