Hey fellows,
-->i want to know about memset,how its work,because when i put 0 or -1 as like as memset(a,-1,a.sizeof(a)) or memset(a,0,a.sizeof(a)),i am getting values,but if i put any other random number,why it is showing garbage values?
--> moreover,can u guys suggest me online best website for learning **cpp(c++).
That is because memset sets values byte by byte. This will not be a problem for 0 or -1, because all the bit values are equal in 0 or -1. However, if you choose any other integer like 5, for example, we will get the following result:
Memset will set each of the 4 bytes of the integer to 5, and this will result in a completely different integer value.
Although, you could have just googled this.
Look at this link :- Link