typedef struct test
{
int numInt;
double numFloat;
bool check;
} TEST;
int main ()
{
int j=0;
TEST *myNum[20];
// I just want an array to hold 20 addresses of TEST structs.
TEST tempTESTS[20]; // Lets create 20 structs as an example.
for (int i=0; i<20; i++)
{
if (tempTESTS[i].numInt > 100)
{
myNum[j] = &tempTESTS[i];
++j;
}
}
print (myNum, j);
}
Edit: I want to store the addresses of the structs that pass certain condition in the "myNum array", and then pass that array to another function to process them (print for example).
Isn't this correct?
For some reason, I'm confused if I should malloc each element of (*myNUM[20]) array before storing the address of "tempTESTS struct". I just want to store the address of a valid struct here. So, I dont think malloc is needed. Could someone clarify? I wish I could chat with a person to clear this :-(
Thanks!