I'm busy writing Yahtzee. Now, I want to fill a const char[] with the field names: 1's, 2's, 3's, ..., "Full House" "Small Straight" etc. But I get this errors
#include <iostream>
#include <stdlib.h>
using namespace std;
/*
1
2
3
4
5
6
3 of a kind
carre
full house
small street
big street
topscore
chance
*/
void RollDice(int DiceToRoll[]);
void ShowScores(int nPlayer);
int Dice[5];
int ScoreField[14][10]; // For max 10 player
const char FieldName[15][14] = {
"Number 1's",
"Number 2's",
"Number 3's",
"Number 4's",
"Number 5's",
"Number 6's",
"Bonus",
"Three-of-a-kind",
"Four-of-a-kind",
"Full House",
"Small straight",
"Large straight",
"Yahtzee",
"Chance"
};
int main()
{
int nNoPlayers;
cout << "Enter number of players" << endl;
cin >> nNoPlayers;
bool bGameOver = false;
while( !bGameOver ) {
for( int n = 0; n < nNoPlayers; n++ ) {
cout << "Player " << n << "'s turn" << endl;
cout << "Pick an option: " << endl
<< "1) Show upper scorefields" << endl
<< "2) Show lower scorefields" << endl
<< "3) (Re)roll dice" << endl;
char cOption;
cin >> cOption;
if( cOption == '1' ) {
ShowScores(n);
}
}
cout << "Play another game (Y/N)?" << endl;
char cAnotherGameYN;
cin >> cAnotherGameYN;
if( cAnotherGameYN == 'N' || cAnotherGameYN == 'n' ) {
bGameOver = true;
}
}
cout << "Game over";
}
// const char FieldName[15][14] = {
void ShowScores(int nPlayer) {
for( int n = 0; n < 13; n++ ) {
cout << FieldName[0][n] << endl;
}
cout << endl;
}
:
||=== Build: Debug in Yahtzee (compiler: GNU GCC Compiler) ===|
E:\Programming\Yahtzee\main.cpp|43|error: initializer-string for array of chars is too long [-fpermissive]|
E:\Programming\Yahtzee\main.cpp|43|error: initializer-string for array of chars is too long [-fpermissive]|
E:\Programming\Yahtzee\main.cpp|43|error: initializer-string for array of chars is too long [-fpermissive]|
E:\Programming\Yahtzee\main.cpp|43|error: initializer-string for array of chars is too long [-fpermissive]|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
What is wrong?