简体   繁体   中英

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.

The 0x00 syntax is for the programmer only. There will be no difference in the compiled code.

I you want to try the experiment yourself quickly you could use gcc explorer .

You would see that the generated assembly is identical.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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