In the coding part while assigning all the elements of the array to be 0, why was memset function use. We could simply use the following syntax
pre[1000005]={0}
Does memset function provide any advantage to use?
Memset function
Yes for 0…both will do the same.
But suppose you want to initialize all locations with 1 or -1… then pre[1000005]={1} will not work. For such case memset can be used. But remember that memset can be use to initialize only with 0,1 or -1.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.