Possible Duplicate:
memcpy vs assignment in C
I wanted to know if there is a gain in performance of assigning a big structure (e.g 100 bytes) automatic variable to zero rather than doing memset it to zero in run time in C. Not sure if gcc compiler can do optimization at compile time for this
以下是2起案件。
<><>Case 1:
void fun1()
{
struct S y = {0};
}
<><>Case2:
void fun1()
{
struct S y;
memset(&y, 0, sizeof(y));
}