Length of Array of Structs

Jan 27, 2010 at 4:39pm
Hello. I couldn't find a good answer to this question, so I thought I might ask it here. I am trying to get the length of an array of structs automatically (how many structs there are in the array). Is there an easy way to do it?
Thank you!
Jan 27, 2010 at 4:43pm
Is it a variable or a function parameter?
You are using built-in auto-allocated arrays?
Jan 27, 2010 at 5:10pm
Well, I first declared a structure single_card, then I used single_card cards[3] to declare the array. Then I tried to pass it into a function, so something like:

1
2
3
void get_card(single_card cards[]) {
...
}


Now I would like to use the length of the array... get it automatically, I guess.
Thanks!
Jan 27, 2010 at 5:17pm
You can't like that. You will need to pass the size manually, or use an STL container.
Jan 27, 2010 at 8:07pm
I see... Thank you so much!
Topic archived. No new replies allowed.