In general ,as per C standard is it guaranteed that memset() with 0 will zero out the padding bits in a C structure?
What about gcc?
For example , something like:
struct MyStruct
{
    unsigned char   member1;
    unsigned int    member2;
    char        member3;
    unsigned char   member4;
    float       member5;    
};
struct MyStruct ms;
memset(&ms, 0, sizeof( struct MyStruct));
Perhaps worth noting that memset doesn't know anything about your struct (or array, or primitive, or any chunk of memory whatsoever that you happen to unleash it on), so even if it wanted to leave the padding bits intact, it wouldn't even know where they are.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With