Is it ok to zero out "sockaddr_in" like this:
Instead of the usual:Code:sockaddr_in clientService = {0};
Code:sockaddr_in clientService; memset( &clientService, 0, sizeof clientService );
Is it ok to zero out "sockaddr_in" like this:
Instead of the usual:Code:sockaddr_in clientService = {0};
Code:sockaddr_in clientService; memset( &clientService, 0, sizeof clientService );
Using Windows 10 with Code Blocks and MingW.
yep, perfectly ok. It may not necessarilly have the effect you intend though. sockaddr_in is a structure, as such you need to zero out every member variable in it.
Last edited by abachler; 04-14-2009 at 04:08 AM.
Thanks Abachler!
I thought this technique works the same for both arrays and structures.
In an array it zeros out every element.
Using Windows 10 with Code Blocks and MingW.
It may work for your particular complilers implimentation, but afaik it is undefined behavior and may not be portable to other compilers.