I am new to C/C++ and am trying to write chess code that will simply output the start chess position (as a text diagram) to the console. (Later I hope to add a move generator and build from here a simple console chess engine- and that will be pretty challenging. As I do this I will learn more about C/C++ programming).
Anyway here is the code I have now (and when I try compiling & running I get error messages and I have spent quite a while trying to fix this and would appreciate some of your help with this):
#include <iostream>
int ChessBoard[8][8];
int main()
{
int ChessBoard[8][8] = {
{'r', 'n', 'b', 'q', 'k', 'b', 'n', 'r'},
{'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P'},
{'R', 'N', 'B', 'Q', 'K', 'B', 'N', 'R'}, };
for (int i = 0; i<8; i++)
for (int j=0; j<8; j++)
{
printf {"'r', 'n', 'b', 'q', 'k', 'b', 'n', 'r',\n"};
printf {"'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p',\n"};
printf {"' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',\n"};
printf {"' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',\n"};
printf {"' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',\n"};
printf {"' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',\n"};
printf {"'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P',\n"};
printf {"'R', 'N', 'B', 'Q', 'K', 'B', 'N', 'R',\n"};
printf( "\n" );
}
return 0;
}
I look forward to help to fix this.Thanks & best wishes

New Topic/Question
Reply




MultiQuote







|