Manic Manic - 3 years ago 168
C Question

What would be the difference between setting a struct sockaddr_in to 0 and '\0' using memset?

I have just started off with C socket programming. I have read that 0 as an integer constant, refers to a null pointer when compared with a pointer and '\0' refers to a null character, something that sets all the bits to 0. And, in the case concerning my question, I know I should probably be using '\0'. But I can see a lot of implementations that uses 0 instead. What would be the difference as such?
I don't wanna go with whatever that works. I can't move on till I understand why.
Thanks!

Answer Source

There is no difference. They are equal.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download