error C2447: missing function header (old-style formal list?)

#include<iostream>
using namespace std;


int main();
{
//1

char board[16] = {};

bool inviboard[16] = {};

int turn = 0;

int n = 1;

char answer;

do
{//2

system("cls");

for(int i=0; i<12; i += 4)
{ // sets the board //3

cout<< board[i] << "|" << board[i+1] << "|" << board[i+2] << "|" << board[i+3] <<endl;

cout<< "-+-+-+-" <<endl;

}//3

cout << board[12] << "|" << board[13] << "|" << board[14] << "|" << board[15] <<endl;

do
{//4

cout << "\nEnter square number: "; // Prompts the location of turn

cin >> n;

} //4
while(inviboard[n-1] == true && n > 0 && n <= 16);

if (turn % 2 == 1)
{//5

cout << "Enter letter: ";

cin >> answer;

board[n-1] = answer;

inviboard[n-1] = true;

}//5

else
{//6

cout << "Enter single number: ";

cin >> answer;

board[n-1] = answer;

inviboard[n-1] = true;

}//6

turn++;

if (board[0] == 'g')
{ // looks if a player won//7

if (board[1] == 'o' && board[2] == 'o' && board[3] == 'd')
{//8

cout << "Player 2 wins";

turn = 15;

}//8

else if(board[4] == 'o' && board[8] == 'o' && board[12] == 'd')
{//9

cout << "Player 2 wins";

turn = 15;

}//9

else if(board[5] == 'o' && board[10] == 'o' && board[15] == 'd')
{//10

cout << "Player 2 wins";

turn = 15;

}//10

}//7

else if (board[1] == 'g' && board[5] == 'o' && board[9] == 'o' && board[13] == 'd')
{//11

cout << "Player 2 wins";

turn = 15;

}//11

else if (board[2] == 'g' && board[6] == 'o' && board[10] == 'o' && board[14] == 'd')
{//12

cout << "Player 2 wins";

turn = 15;

}//12

else if (board[3] == 'g' && board[7] == 'o' && board[11] == 'o' && board[15] == 'd')
{//13

cout << "Player 2 wins";

turn = 15;

}//13

else if (board[4] == 'g' && board[5] == 'o' && board[6] == 'o' && board[7] == 'd')
{//14

cout << "Player 2 wins";

turn = 15;

}//14

else if (board[8] == 'g' && board[9] == 'o' && board[10] == 'o' && board[11] == 'd')
{//15

cout << "Player 2 wins";

turn = 15;

}//15

else if (board[12] == 'g')
{//16

if (board[13] == 'o' && board[14] == 'o' && board[15] == 'd')
{//17

cout << "Player 2 wins";

turn = 15;

}//17

if (board[9] == 'o' && board[6] == 'o' && board[3] == 'd')
{//18

cout << "Player 2 wins";

turn = 15;

}//18

}//16

if (board[0] == '1')
{//19

if (board[1] == '4' && board[2] == '3' && board[3] == '4')
{//20

cout << "Player 1 wins";

turn = 15;

}//20

else if(board[4] == '4' && board[8] == '3' && board[12] == '4')
{//21

cout << "Player 1 wins";

turn = 15;

}//21

else if(board[5] == '4' && board[10] == '3' && board[15] == '4')
{//22

cout << "Player 1 wins";

turn = 15;

}//22

}//19

else if (board[1] == '1' && board[5] == '4' && board[9] == '3' && board[13] == '4')
{//23

cout << "Player 1 wins";

turn = 15;

}//23

else if (board[2] == '1' && board[6] == '4' && board[10] == '3' && board[14] == '4')
{//24

cout << "Player 1 wins";

turn = 15;

}//24

else if (board[3] == '1' && board[7] == '4' && board[11] == '3' && board[15] == '4')
{//25

cout << "Player 1 wins";

turn = 15;

}//25

else if (board[4] == '1' && board[5] == '4' && board[6] == '3' && board[7] == '4')
{//26

cout << "Player 1 wins";

turn = 15;

}//26

else if (board[8] == '1' && board[9] == '4' && board[10] == '3' && board[11] == '4')
{//27

cout << "Player 1 wins";

turn = 15;

}//27

else if (board[12] == '1')
{//28

if (board[13] == '4' && board[14] == '3' && board[15] == '4')
{//29

cout << "Player 1 wins";

turn = 15;

}//29

if (board[9] == '4' && board[6] == '3' && board[3] == '4')
{//30


cout << "Player 1 wins";

turn = 15;

}//30

}//28

if (turn == 15)
{//31

cout << "\nDo you want to play again(y/n)?"; //Prompts the user to play again

cin >> answer;

if (answer == 'y' || answer == 'Y')
{//32

for (int i = 0; i < 16; i++)
{//33

board[i] = 0;

inviboard[i] = false;

}//33

turn = 0;

n = 1;

}//32

else
{//34

cout << "Thanks for Playing!";

system("pause>0");

exit(1);

}//34
}//31

system("pause>0");
}//2
while(turn < 16);
return 0;
}//1

Can you help me in debugging?
What should I do now?
int main()

No semi-colon.

Are you this guy - http://www.cplusplus.com/forum/beginner/63920/ - as well, or do you all copy code from the same place?
Last edited on
#include<iostream.h>

int main();
cdecl main(void);
{
//1

char board[16] = {};

bool inviboard[16] = {};

int turn = 0;

int n = 1;

char answer;

do
{//2

system("cls");

for(int i=0; i<12; i += 4)
{ // sets the board //3

cout<< board[i] << "|" << board[i+1] << "|" << board[i+2] << "|" << board[i+3] <<endl;

cout<< "-+-+-+-" <<endl;

}//3

cout << board[12] << "|" << board[13] << "|" << board[14] << "|" << board[15] <<endl;

do
{//4

cout << "\nEnter square number: "; // Prompts the location of turn

cin >> n;

} //4
while(inviboard[n-1] == true && n > 0 && n <= 16);

if (turn % 2 == 1)
{//5

cout << "Enter letter: ";

cin >> answer;

board[n-1] = answer;

inviboard[n-1] = true;

}//5

else
{//6

cout << "Enter single number: ";

cin >> answer;

board[n-1] = answer;

inviboard[n-1] = true;

}//6

turn++;

if (board[0] == 'g')
{ // looks if a player won//7

if (board[1] == 'o' && board[2] == 'o' && board[3] == 'd')
{//8

cout << "Player 2 wins";

turn = 15;

}//8

else if(board[4] == 'o' && board[8] == 'o' && board[12] == 'd')
{//9

cout << "Player 2 wins";

turn = 15;

}//9

else if(board[5] == 'o' && board[10] == 'o' && board[15] == 'd')
{//10

cout << "Player 2 wins";

turn = 15;

}//10

}//7

else if (board[1] == 'g' && board[5] == 'o' && board[9] == 'o' && board[13] == 'd')
{//11

cout << "Player 2 wins";

turn = 15;

}//11

else if (board[2] == 'g' && board[6] == 'o' && board[10] == 'o' && board[14] == 'd')
{//12

cout << "Player 2 wins";

turn = 15;

}//12

else if (board[3] == 'g' && board[7] == 'o' && board[11] == 'o' && board[15] == 'd')
{//13

cout << "Player 2 wins";

turn = 15;

}//13

else if (board[4] == 'g' && board[5] == 'o' && board[6] == 'o' && board[7] == 'd')
{//14

cout << "Player 2 wins";

turn = 15;

}//14

else if (board[8] == 'g' && board[9] == 'o' && board[10] == 'o' && board[11] == 'd')
{//15

cout << "Player 2 wins";

turn = 15;

}//15

else if (board[12] == 'g')
{//16

if (board[13] == 'o' && board[14] == 'o' && board[15] == 'd')
{//17

cout << "Player 2 wins";

turn = 15;

}//17

if (board[9] == 'o' && board[6] == 'o' && board[3] == 'd')
{//18

cout << "Player 2 wins";

turn = 15;

}//18

}//16

if (board[0] == '1')
{//19

if (board[1] == '4' && board[2] == '3' && board[3] == '4')
{//20

cout << "Player 1 wins";

turn = 15;

}//20

else if(board[4] == '4' && board[8] == '3' && board[12] == '4')
{//21

cout << "Player 1 wins";

turn = 15;

}//21

else if(board[5] == '4' && board[10] == '3' && board[15] == '4')
{//22

cout << "Player 1 wins";

turn = 15;

}//22

}//19

else if (board[1] == '1' && board[5] == '4' && board[9] == '3' && board[13] == '4')
{//23

cout << "Player 1 wins";

turn = 15;

}//23

else if (board[2] == '1' && board[6] == '4' && board[10] == '3' && board[14] == '4')
{//24

cout << "Player 1 wins";

turn = 15;

}//24

else if (board[3] == '1' && board[7] == '4' && board[11] == '3' && board[15] == '4')
{//25

cout << "Player 1 wins";

turn = 15;

}//25

else if (board[4] == '1' && board[5] == '4' && board[6] == '3' && board[7] == '4')
{//26

cout << "Player 1 wins";

turn = 15;

}//26

else if (board[8] == '1' && board[9] == '4' && board[10] == '3' && board[11] == '4')
{//27

cout << "Player 1 wins";

turn = 15;

}//27

else if (board[12] == '1')
{//28

if (board[13] == '4' && board[14] == '3' && board[15] == '4')
{//29

cout << "Player 1 wins";

turn = 15;

}//29

if (board[9] == '4' && board[6] == '3' && board[3] == '4')
{//30


cout << "Player 1 wins";

turn = 15;

}//30

}//28

if (turn == 15)
{//31

cout << "\nDo you want to play again(y/n)?"; //Prompts the user to play again

cin >> answer;

if (answer == 'y' || answer == 'Y')
{//32

for (int i = 0; i < 16; i++)
{//33

board[i] = 0;

inviboard[i] = false;

}//33

turn = 0;

n = 1;

}//32

else
{//34

cout << "Thanks for Playing!";

system("pause>0");

exit(1);

}//34
}//31

system("pause>0");
}//2
while(turn < 16);
return 0;
}//1


How about in this? What do i still need to input?
You DIDN'T MAKE THE CHANGE. I told you what to change and you didn't.
#include<iostream.h>

int main()
cdecl main(void)
{
//1

char board[16] = {};

bool inviboard[16] = {};

int turn = 0;

int n = 1;

char answer;

do
{//2

system("cls");

for(int i=0; i<12; i += 4)
{ // sets the board //3

cout<< board[i] << "|" << board[i+1] << "|" << board[i+2] << "|" << board[i+3] <<endl;

cout<< "-+-+-+-" <<endl;

}//3

cout << board[12] << "|" << board[13] << "|" << board[14] << "|" << board[15] <<endl;

do
{//4

cout << "\nEnter square number: "; // Prompts the location of turn

cin >> n;

} //4
while(inviboard[n-1] == true && n > 0 && n <= 16);

if (turn % 2 == 1)
{//5

cout << "Enter letter: ";

cin >> answer;

board[n-1] = answer;

inviboard[n-1] = true;

}//5

else
{//6

cout << "Enter single number: ";

cin >> answer;

board[n-1] = answer;

inviboard[n-1] = true;

}//6

turn++;

if (board[0] == 'g')
{ // looks if a player won//7

if (board[1] == 'o' && board[2] == 'o' && board[3] == 'd')
{//8

cout << "Player 2 wins";

turn = 15;

}//8

else if(board[4] == 'o' && board[8] == 'o' && board[12] == 'd')
{//9

cout << "Player 2 wins";

turn = 15;

}//9

else if(board[5] == 'o' && board[10] == 'o' && board[15] == 'd')
{//10

cout << "Player 2 wins";

turn = 15;

}//10

}//7

else if (board[1] == 'g' && board[5] == 'o' && board[9] == 'o' && board[13] == 'd')
{//11

cout << "Player 2 wins";

turn = 15;

}//11

else if (board[2] == 'g' && board[6] == 'o' && board[10] == 'o' && board[14] == 'd')
{//12

cout << "Player 2 wins";

turn = 15;

}//12

else if (board[3] == 'g' && board[7] == 'o' && board[11] == 'o' && board[15] == 'd')
{//13

cout << "Player 2 wins";

turn = 15;

}//13

else if (board[4] == 'g' && board[5] == 'o' && board[6] == 'o' && board[7] == 'd')
{//14

cout << "Player 2 wins";

turn = 15;

}//14

else if (board[8] == 'g' && board[9] == 'o' && board[10] == 'o' && board[11] == 'd')
{//15

cout << "Player 2 wins";

turn = 15;

}//15

else if (board[12] == 'g')
{//16

if (board[13] == 'o' && board[14] == 'o' && board[15] == 'd')
{//17

cout << "Player 2 wins";

turn = 15;

}//17

if (board[9] == 'o' && board[6] == 'o' && board[3] == 'd')
{//18

cout << "Player 2 wins";

turn = 15;

}//18

}//16

if (board[0] == '1')
{//19

if (board[1] == '4' && board[2] == '3' && board[3] == '4')
{//20

cout << "Player 1 wins";

turn = 15;

}//20

else if(board[4] == '4' && board[8] == '3' && board[12] == '4')
{//21

cout << "Player 1 wins";

turn = 15;

}//21

else if(board[5] == '4' && board[10] == '3' && board[15] == '4')
{//22

cout << "Player 1 wins";

turn = 15;

}//22

}//19

else if (board[1] == '1' && board[5] == '4' && board[9] == '3' && board[13] == '4')
{//23

cout << "Player 1 wins";

turn = 15;

}//23

else if (board[2] == '1' && board[6] == '4' && board[10] == '3' && board[14] == '4')
{//24

cout << "Player 1 wins";

turn = 15;

}//24

else if (board[3] == '1' && board[7] == '4' && board[11] == '3' && board[15] == '4')
{//25

cout << "Player 1 wins";

turn = 15;

}//25

else if (board[4] == '1' && board[5] == '4' && board[6] == '3' && board[7] == '4')
{//26

cout << "Player 1 wins";

turn = 15;

}//26

else if (board[8] == '1' && board[9] == '4' && board[10] == '3' && board[11] == '4')
{//27

cout << "Player 1 wins";

turn = 15;

}//27

else if (board[12] == '1')
{//28

if (board[13] == '4' && board[14] == '3' && board[15] == '4')
{//29

cout << "Player 1 wins";

turn = 15;

}//29

if (board[9] == '4' && board[6] == '3' && board[3] == '4')
{//30


cout << "Player 1 wins";

turn = 15;

}//30

}//28

if (turn == 15)
{//31

cout << "\nDo you want to play again(y/n)?"; //Prompts the user to play again

cin >> answer;

if (answer == 'y' || answer == 'Y')
{//32

for (int i = 0; i < 16; i++)
{//33

board[i] = 0;

inviboard[i] = false;

}//33

turn = 0;

n = 1;

}//32

else
{//34

cout << "Thanks for Playing!";

system("pause>0");

exit(1);

}//34
}//31

system("pause>0");
}//2
while(turn < 16);
return 0;
}//1

now i made the change. why are there so many errors? Please help me ! Please!
It's for my project!
Remove "cdecl main(void)"
#include<iostream.h>

int main()
{
//1

char board[16] = {};

bool inviboard[16] = {};

int turn = 0;

int n = 1;

char answer;

do
{//2

system("cls");

for(int i=0; i<12; i += 4)
{ // sets the board //3

cout<< board[i] << "|" << board[i+1] << "|" << board[i+2] << "|" << board[i+3] <<endl;

cout<< "-+-+-+-" <<endl;

}//3

cout << board[12] << "|" << board[13] << "|" << board[14] << "|" << board[15] <<endl;

do
{//4

cout << "\nEnter square number: "; // Prompts the location of turn

cin >> n;

} //4
while(inviboard[n-1] == true && n > 0 && n <= 16);

if (turn % 2 == 1)
{//5

cout << "Enter letter: ";

cin >> answer;

board[n-1] = answer;

inviboard[n-1] = true;

}//5

else
{//6

cout << "Enter single number: ";

cin >> answer;

board[n-1] = answer;

inviboard[n-1] = true;

}//6

turn++;

if (board[0] == 'g')
{ // looks if a player won//7

if (board[1] == 'o' && board[2] == 'o' && board[3] == 'd')
{//8

cout << "Player 2 wins";

turn = 15;

}//8

else if(board[4] == 'o' && board[8] == 'o' && board[12] == 'd')
{//9

cout << "Player 2 wins";

turn = 15;

}//9

else if(board[5] == 'o' && board[10] == 'o' && board[15] == 'd')
{//10

cout << "Player 2 wins";

turn = 15;

}//10

}//7

else if (board[1] == 'g' && board[5] == 'o' && board[9] == 'o' && board[13] == 'd')
{//11

cout << "Player 2 wins";

turn = 15;

}//11

else if (board[2] == 'g' && board[6] == 'o' && board[10] == 'o' && board[14] == 'd')
{//12

cout << "Player 2 wins";

turn = 15;

}//12

else if (board[3] == 'g' && board[7] == 'o' && board[11] == 'o' && board[15] == 'd')
{//13

cout << "Player 2 wins";

turn = 15;

}//13

else if (board[4] == 'g' && board[5] == 'o' && board[6] == 'o' && board[7] == 'd')
{//14

cout << "Player 2 wins";

turn = 15;

}//14

else if (board[8] == 'g' && board[9] == 'o' && board[10] == 'o' && board[11] == 'd')
{//15

cout << "Player 2 wins";

turn = 15;

}//15

else if (board[12] == 'g')
{//16

if (board[13] == 'o' && board[14] == 'o' && board[15] == 'd')
{//17

cout << "Player 2 wins";

turn = 15;

}//17

if (board[9] == 'o' && board[6] == 'o' && board[3] == 'd')
{//18

cout << "Player 2 wins";

turn = 15;

}//18

}//16

if (board[0] == '1')
{//19

if (board[1] == '4' && board[2] == '3' && board[3] == '4')
{//20

cout << "Player 1 wins";

turn = 15;

}//20

else if(board[4] == '4' && board[8] == '3' && board[12] == '4')
{//21

cout << "Player 1 wins";

turn = 15;

}//21

else if(board[5] == '4' && board[10] == '3' && board[15] == '4')
{//22

cout << "Player 1 wins";

turn = 15;

}//22

}//19

else if (board[1] == '1' && board[5] == '4' && board[9] == '3' && board[13] == '4')
{//23

cout << "Player 1 wins";

turn = 15;

}//23

else if (board[2] == '1' && board[6] == '4' && board[10] == '3' && board[14] == '4')
{//24

cout << "Player 1 wins";

turn = 15;

}//24

else if (board[3] == '1' && board[7] == '4' && board[11] == '3' && board[15] == '4')
{//25

cout << "Player 1 wins";

turn = 15;

}//25

else if (board[4] == '1' && board[5] == '4' && board[6] == '3' && board[7] == '4')
{//26

cout << "Player 1 wins";

turn = 15;

}//26

else if (board[8] == '1' && board[9] == '4' && board[10] == '3' && board[11] == '4')
{//27

cout << "Player 1 wins";

turn = 15;

}//27

else if (board[12] == '1')
{//28

if (board[13] == '4' && board[14] == '3' && board[15] == '4')
{//29

cout << "Player 1 wins";

turn = 15;

}//29

if (board[9] == '4' && board[6] == '3' && board[3] == '4')
{//30


cout << "Player 1 wins";

turn = 15;

}//30

}//28

if (turn == 15)
{//31

cout << "\nDo you want to play again(y/n)?"; //Prompts the user to play again

cin >> answer;

if (answer == 'y' || answer == 'Y')
{//32

for (int i = 0; i < 16; i++)
{//33

board[i] = 0;

inviboard[i] = false;

}//33

turn = 0;

n = 1;

}//32

else
{//34

cout << "Thanks for Playing!";

system("pause>0");

exit(1);

}//34
}//31

system("pause>0");
while(turn < 16);
return 0;
}//1

Thank you for your kind cooperation.
How bout in this?
You ADDED cdecl main(void)? Why would you do that?

What are you compiling this with anyway? You're using pre-standard C++ code from over a decade ago.
Topic archived. No new replies allowed.