By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,413 Members | 999 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,413 IT Pros & Developers. It's quick & easy.

Problem with a struct within a struct

P: 1
Hi I'm having trouble understanding how structs work ...

i have two structs ...

struct card{
int value;
string name;


struct deck{
int currentcardontop;
int decksize;
card cards[40];

My question is if I'm trying to access the "currentcardontop" and then find the "name" associated with that card from the card struct ... how would I go about doing that?

currently, I have something along the lines of:
struct deck ONE;

and then[currentcardontop].name .... it just seems really off to me cause of my complete lack of understanding for structures ... could someone please help me understand these things?
Nov 2 '06 #1
Share this Question
Share on Google+
1 Reply

P: 4
one thing i can tell, what u have is not a structure in structure. the currentcardontop should be a type of card.

in ur struct use
struct card currentcardontop
Nov 3 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.