is memset() more efficient than for loop in C?

前端 未结 7 1417
不思量自难忘°
不思量自难忘° 2021-02-02 06:46

is memset more efficient than for loop. so if i have

char x[500];
memset(x,0,sizeof(x));

or

char x[500];
for(int i = 0 ; i &         


        
7条回答
  •  庸人自扰
    2021-02-02 07:04

    Agree with above. It depends. But, for sure memset is faster or equal to the for-loop. If you are uncertain of your environment or too lazy to test, take the safe route and go with memset.

提交回复
热议问题