Reputation: 331
I have 2 structures:
typedef struct
{
int a;
} S1;
typedef struct
{
S1[0xff];
} S2;
Let's say I only require the element 0xf0 out of S2->S1, and the rest will be zero or whatever, unimportant.
I fill the struct like such:
S2 g_s2[] = {
// 0x00
{ 0 },
// 0x01
{ 1 }
}
Is there some way to pad the first X number of elements so I dont have to type {0},{0},{0}, 200 times to get there?
Upvotes: 2
Views: 53
Reputation: 2567
S2 g_s2[] = { [0xf0] = 12 };
Here, we are initializing only 0xf0
th element to 12, remaining elements of the array will be zero.
Upvotes: 2