Danya already provided the answer to this question.
As far as your reply is concerned, the first case is not correct. How do you think the compiler initializes memory?
Both the options will be equally good as far as speed is concerned and the second option will not work for non trivial types (non POD types) as already pointed out
That's the thing, I don't need to "think" how the compiler initializes the memory. I can just ask, and I will know for a fact. In order to compile the code, I supposed the type was a char[16].
In this case, GCC will do exactly the same thing for any of the following pieces of code:
1) char x[16] = {0};
2) char x[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
3) char x[16]; memset(x, 0, sizeof(char[16]));
And this is how GCC tells me it will do:
xorl %eax, %eax
The funny thing is why does it write that assembly instead of this:
mov eax,0x0
Apparently, the xor code is faster than the mov one, and that's what GCC will do when you use the -O3 switch.