I see it in codes that once they zerod out a struct they set a few elements to NULL.
Is it really necessary or is it redundant?
Code:ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = NULL;
I see it in codes that once they zerod out a struct they set a few elements to NULL.
Is it really necessary or is it redundant?
Code:ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = NULL;
Using Windows 10 with Code Blocks and MingW.
Some tests become quite simple:
It will NOT help the program keep running, even though it has poor logic.Code:if(somePointer) //do something constructive if the pointer has been //given a good address. else //it's still a NULL value, so //give the pointer a good address
It's necessary for maximally portable code. There's no guarantee that null pointers are all bits zero. The same goes for floating point: 0.0 isn't necessary all bits zero. C99 (well, one of its technical corrigenda) does require that integers with all bits zero be set to zero. The implication is that C90 didn't require this, but this is probably one of those assumptions that you can safely assume will hold even though it wasn't required.
Thank you cas and Adak i understand it better.
Using Windows 10 with Code Blocks and MingW.