Coding Global Background
Coding Global

C compiler error when initializing a 2d char arry

Archiviert 2 years ago
5 Nachrichten
1 Mitglieder
Erstellt 2 years ago
Aktualisiert 2 years ago
In Discord öffnen
J
JustSa
Verified
When I try to initialize a 2d 8 by 8 char array I get the error error: expected expression before '{' token. Can someone explain me why this is happening? Code:
char piecesOnBoard[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'}};

Antworten (5)