- Joined
- Feb 4, 2011
- Messages
- 1
- Reaction score
- 0
Hi
Id like to put a pointer to an array within a struct. Id also like to define the contents of that array at compile time, in a similar way to the assignment of strings. Ive tried every combination that i can think of, but cant get it to work. The arrays have differing lengths, but since they're known at compile time it shouldnt be a problem. It works for strings, so there should be no difference right?
Any ideas?? I can make it work by defining separate arrays, then pointing the pointers at them, but its not pretty code. It would be great if I could do it similar to the way shown here.
Id like to put a pointer to an array within a struct. Id also like to define the contents of that array at compile time, in a similar way to the assignment of strings. Ive tried every combination that i can think of, but cant get it to work. The arrays have differing lengths, but since they're known at compile time it shouldnt be a problem. It works for strings, so there should be no difference right?
Code:
typedef struct
{
char* String;
int* uintArray_arr;
} S_Struct;
S_Struct S1 =
{
"Description",
{INT1,INT2,INT3}
}
S_Struct S2 =
{
"Description that is longer",
{INT1,INT2,INT3,EXTRA_INT}
}
Any ideas?? I can make it work by defining separate arrays, then pointing the pointers at them, but its not pretty code. It would be great if I could do it similar to the way shown here.