简体   繁体   English

memset 0和0X00

[英]memset with 0 and 0X00

Is there any difference in the below lines: 以下几行有什么不同:

char myname[512]; -- created a character array and wants to memset it.

Is there any difference in the below two lines. 以下两行有什么不同。

memset (&myname, 0x00, sizeof(myname));
memset (&myname, 0, sizeof(myname));

I am pretty sure that both will nullify the myname array. 我很确定两者都会使myname数组无效。

The 0x00 syntax is for the programmer only. 0x00语法仅适用于程序员。 There will be no difference in the compiled code. 编译代码没有区别。

I you want to try the experiment yourself quickly you could use gcc explorer . 我想你自己快速尝试一下你可以使用gcc explorer

You would see that the generated assembly is identical. 您会看到生成的程序集是相同的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM