Assigning a variable length array within a structure.

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?

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top