Coding Global Background
Coding Global

C compiler error when initializing a 2d char arry

Archived 2 years ago
5 messages
1 members
2 years ago
Open in Discord
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'}};

Replies (5)