#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"};
我想声明这种类型的数组,但它总是会产生错误,例如&#34;太多的初始化器和#34;。我该如何解决这个错误?
答案 0 :(得分:3)
你想做的就是这个:
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"}};
无论如何已经建议std::vector
和std::string
应该是首选的
答案 1 :(得分:2)
C ++方式将使用类似std::string
的字符串类和类似std::vector
的容器(不是原始的C样式char
字符串和原始数组),例如:
vector<vector<vector<string>>> x;
如果你真正想要的是一个二维字符串数组,那就是:
vector<vector<string>> x;