I have an array of 3 elements. But I only want to initialize 2 of them. I allow the third element.
unsigned char array[3] = {1,2,}; int main(){ printf("%d",array[2]); return 0; }
The print result is 0. I tested it on the IAR and in the online compiler.
Is there any C rule for the value of the third element? Is there any compiler populating the third element with 0xFF? (Especially the cross compiler)
c arrays initialization
Ngo thanh nhan
source share