Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
memset has the signature
[code]void *memset(void *s, int c, size_t n);[/code]
Anyone know what happens if you call it this way??
[code]memset([size=3][blue]NULL[/blue][/size], , );[/code]
I'm wondering if sees the NULL and then knows not to do anything (like a no-op) or if it will crash/something-else because it's trying to access the NULL... Or is the whole situation just undefined...???
I can't find any documentation or examples that tells what happens in this case... Of course I could write a quick test program, but it would be platform-specific, and I want to know if there is a standard definition of this behaviour... My point is, I have a lot of code to zero out a structure tree with lots of pointers, and I'm hoping there's some way that it will be smart and do a no-op... Otherwise, everywhere I could potentially have a NULL pointer, I'm going to have to go add
memset(ptr, 0, );[/code]
And I really don't want to have to do that...
0 · ·