0

In the following code:

typedef struct 
{
    uint32_t variable_1;
}struct_1;

typedef struct 
{
    uint32_t variable_2;
}struct_2;

typedef struct 
{
    struct_1 struct_1_var;
    struct_2 struct_2_var;
}struct_all;


struct_all variable_t[10];

struct_1* struct_1_var; //how to get this to point to an array of struct_1 that's inside variable_t?

Basically, I want to get an struct_1[10] or struct_2[10] that that is part of variable_t[10].

1 Answer 1

4

You can't, because there isn't an array of either struct_1s or struct_2s in variable_t to point to. There is an array of elements, each of which has a struct_1 and a struct_2.

If you want an array of just one type of the other of the values in variable_t, you'll need to copy them out one at a time into a new array.

Sign up to request clarification or add additional context in comments.

1 Comment

That is what I was afraid of. Thought that there was a way to do it without one at a time. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.