结构体数组的问题
发布网友
发布时间:2023-09-14 12:02
我来回答
共1个回答
热心网友
时间:2024-08-05 10:32
#include<stdio.h>
#include<string.h>
typedef enum suits {
clubs,
diamonds,
hearts,
spades
} suits;
typedef enum values {
zero, // used to signal invalid cards (and hands)
one, // not used, but ensures numerical values correspond
two,
three,
four,
five,
six,
seven,
eight,
nine,
ten,
jack,
queen,
king,
ace
} values;
typedef struct cards {
suits suit;
values value;
} cards;
int parsesuit(suits *suitPtr, char ch)
{
return 1;//1为转换成功,0为无效字符
}
int parsevalue(values *valuePtr, char ch)
{
return 1;//..... //同上
}
int cardsread(cards* handread, char* input)
{
if(parsevalue(&(handread->value),input[1])==1)
{
}
return 1;
}
void initfive(cards* handread)
{
char input[32];
scanf("s%",input);//用户输入5张牌
cardsread(handread, input);
//...
}
int main()
{
cards handread[5];
initfive(handread);
return 0;
}追问如果我对handread进行遍历呢?