Reputation: 1
#include<stdio.h>
char count[3][5][14]={{"♠1","♠2","♠3","♠4","♠5","♠6","♠7","♠8","♠9","♠10","♠J","♠Q","♠K"},
{"◇1","◇2","◇3","◇4","◇5","◇6","◇7","◇8","◇9","◇10","◇J","◇Q","◇K"},
{"♣1","♣2","♣3","♣4","♣5","♣6","♣7","♣8","♣9","♣10","♣J","♣Q","♣K"},
{"♡1","♡2","♡3","♡4","♡5","♡6","♡7","♡8","♡9","♡10","♡J","♡Q","♡K"};
I want to declare this type of array but it always makes errors such as"Too many initializers". How can I fix this error?
Upvotes: 0
Views: 173
Reputation: 2790
What you want to do is maybe this:
const char * count[4][13]= {{"♠1","♠2","♠3","♠4","♠5","♠6","♠7","♠8","♠9","♠10","♠J","♠Q","♠K"},
{"◇1","◇2","◇3","◇4","◇5","◇6","◇7","◇8","◇9","◇10","◇J","◇Q","◇K"},
{"♣1","♣2","♣3","♣4","♣5","♣6","♣7","♣8","♣9","♣10","♣J","♣Q","♣K"},
{"♡1","♡2","♡3","♡4","♡5","♡6","♡7","♡8","♡9","♡10","♡J","♡Q","♡K"}};
Anyway as already suggested std::vector
and std::string
should be preferred
Upvotes: 3
Reputation: 42964
The C++ way would be using a string class like std::string
and a container like std::vector
(not raw C-style char
strings and raw arrays), e.g.:
vector<vector<vector<string>>> x;
If what you really want is a two-dimension string array, then that would be:
vector<vector<string>> x;
Upvotes: 2