发牌程序,帮忙找错.谢谢
DEV C++报错:excess elements in char array initializer (near initialization for `suit')
excess elements in char array initializer
(near initialization for `face')
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
struct CARD
{ char suit;
char face; };
main()
{
struct CARD card[52];
struct CARD tempcard;
int i, j, s=0, f=0;
char suit[]={"Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"};
char face[]={"Heart","Club","Diamond","Spade"};
/*初始化牌组*/
srand(time(NULL));
for(i=0;i<=51;i++)
{card[i].suit=suit[s];
card[i].face=face[f];
s=(s+1)%13;
f=(f+1)%4;}
/*洗牌*/
for(i=0;i<=51;i++)
{
j=rand()%52;
tempcard.suit=card[i].suit;
tempcard.face=card[i].face;
card[i].suit=card[j].suit;
card[i].face=card[j].face;
card[j].suit=tempcard.suit;
card[j].face=tempcard.face;
}
for(i=0;i<=51;i++)
printf("%s of %s\n",card[i].suit,card[i].face);
system("pause");
}
[[italic] 本帖最后由 寂寞的天空 于 2008-1-12 17:07 编辑 [/italic]]