![]() |
| | #1 |
| Registered User Join Date: Dec 2007 Location: France
Posts: 430
| sockaddr_in Code: sockaddr_in clientService = {0};
Code: sockaddr_in clientService; memset( &clientService, 0, sizeof clientService );
__________________ Using Code::Blocks,MingW with Windows. |
| Ducky is offline | |
| | #2 |
| Malum in se Join Date: Apr 2007
Posts: 3,188
| 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.
__________________ Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off. Last edited by abachler; 04-14-2009 at 04:08 AM. |
| abachler is offline | |
| | #3 |
| Registered User Join Date: Dec 2007 Location: France
Posts: 430
| Thanks Abachler! I thought this technique works the same for both arrays and structures. In an array it zeros out every element.
__________________ Using Code::Blocks,MingW with Windows. |
| Ducky is offline | |
| | #4 |
| Malum in se Join Date: Apr 2007
Posts: 3,188
| It may work for your particular complilers implimentation, but afaik it is undefined behavior and may not be portable to other compilers.
__________________ Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off. |
| abachler is offline | |
| | #5 |
| Registered User Join Date: Sep 2004 Location: California
Posts: 3,020
| |
| bithub is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|