rossmc
12-20-2008, 06:50 PM
I am creating a connect 4 game in C++ and in the past it has worked when i have compiled it but i have just re installed ubuntu on my computer and pasted the code in but when i go to compile the code i get this error
board.cpp: In function ‘int main()’:
board.cpp:77: error: expected `}' at end of input
board.cpp:77: error: expected `}' at end of input
If i add a } to row 77 and compile it i get that error and the same if i take the } out
Just wondering if someone could have a look and tell me what i am doing wrong
This is my code
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <limits>
using std::cout;
using std::cin;
using std::endl;
int main()
{
char a[] = {'|','_','|','_','|','_','|','_','|','_','|','_','|','_','|'};
char b[] = {'|','1','|','2','|','3','|','4','|','5','|','6','|','7','|'};
char board[6][7];
int i, j, k =0;
int row;
int column;
int game =1;
for (i=0; i<6; i++)
for (j=0; j<7; j++)
board[i][j] = ' ';
cout<<" ";
for( j = 0; j<15; j++)
cout <<b[j];
cout <<endl;
for ( i=0; i<6; i++)
{ cout <<i+1;
for( j = 0; j<15; j++)
cout <<a[j];
cout <<endl;
}
while(game ==1)
{
cout << "Player 1 Your Turn Please Enter Which Cell You Would Like" << endl;
cin >> row >> column;
if(board[row-1][column-1] ==' '){
board[row-1][column-1] = 'X';
}
// game over
Thanks Ross
board.cpp: In function ‘int main()’:
board.cpp:77: error: expected `}' at end of input
board.cpp:77: error: expected `}' at end of input
If i add a } to row 77 and compile it i get that error and the same if i take the } out
Just wondering if someone could have a look and tell me what i am doing wrong
This is my code
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <limits>
using std::cout;
using std::cin;
using std::endl;
int main()
{
char a[] = {'|','_','|','_','|','_','|','_','|','_','|','_','|','_','|'};
char b[] = {'|','1','|','2','|','3','|','4','|','5','|','6','|','7','|'};
char board[6][7];
int i, j, k =0;
int row;
int column;
int game =1;
for (i=0; i<6; i++)
for (j=0; j<7; j++)
board[i][j] = ' ';
cout<<" ";
for( j = 0; j<15; j++)
cout <<b[j];
cout <<endl;
for ( i=0; i<6; i++)
{ cout <<i+1;
for( j = 0; j<15; j++)
cout <<a[j];
cout <<endl;
}
while(game ==1)
{
cout << "Player 1 Your Turn Please Enter Which Cell You Would Like" << endl;
cin >> row >> column;
if(board[row-1][column-1] ==' '){
board[row-1][column-1] = 'X';
}
// game over
Thanks Ross