+ 5
What does this code do can you explain plse?
4 odpowiedzi
+ 2
HonFu i don't get your point can you explain briefly plse
+ 1
Hm, funny.
With C you never know (unless you *know*) if it's undefined behaviour.
If we ignore that, by using index notation within an array literal, you just seem to be saying:
'Write x to element [47].'
You write the first three elements, then you jump (initializing the values in between with 0), then restart writing at the indexed point.
+ 1
int a[50] = {1, 2, 3};
would set only the first three values, and the remaining 47 values will be auto-initialized to zero.
After you initialized the array normally, you can define specific array slots like this:
a[47] = 5;
Now your phrase seems to combine this: First three values are regularly initialized, and then suddenly we jump to slot 47 and continue writing from there.
int a = {1,2,3,
[47]=47,50,60};
I have never seen this, and I don't know if this is valid C code or one of the many things in C which you you can do, but shouldn't, because they might work, but maybe won't (aka 'undefined behavior' ).