I have a structure:
struct KeyPair
{
int nNum;
string str;
};
Let's say I initialize my structure:
KeyPair keys[] = {{0, "tester"},
{2, "yadah"},
{0, "tester"}
};
I would create several instances of the structure with different sizes. Therefore, in order for me to use it in a loop and read its contents, I need to get the number of elements in the structure. How to get the number of elements in the structure? In this example, I should get 3, since I initialized 3 pairs.
source
share