-
How can I get to a struct inside a struct???
Hello all...Quick (hopefully) question: I have these structs:
struct CARDS
{
int tagNumber;
int number;
char face;
char suit;
int value;
int sort;
};
struct PLAYER
{
char name [15];
CARDS hand [15];
int handValue;
int handIndex;
};
CARDS deck [52];
PLAYER one;
I want to assign a value (x) into the tagNumber, number, face, suit, value,
and sort variables from within a function. This syntax is wrong according
to the compiler:
one.hand.suit = x;
What is the correct syntax??? Can anyone help me??? -- SarahKate
-
Re: How can I get to a struct inside a struct???
SarahKate wrote:
>
> Hello all...Quick (hopefully) question: I have these structs:
> struct CARDS
> {
> int tagNumber;
> int number;
> char face;
> char suit;
> int value;
> int sort;
> };
> struct PLAYER
> {
> char name [15];
> CARDS hand [15];
> int handValue;
> int handIndex;
>
> };
>
> CARDS deck [52];
> PLAYER one;
>
> I want to assign a value (x) into the tagNumber, number, face, suit, value,
> and sort variables from within a function. This syntax is wrong according
> to the compiler:
> one.hand.suit = x;
> What is the correct syntax??? Can anyone help me??? -- SarahKate
try
one.hand[0].suit = x;
remember that hand is an array, not a single struct.
Danny
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks