News for hackers. Stuff that matters.
Re:C Legacy Is Evil by dezgeg on Tuesday November 04, 2014 @04:33PM (#8559157)
There's also a way to do this without any user-defined functions that works in both C and C++:

    struct tm tm_struct = { 0, };
Re:C Legacy Is Evil by cremno on Tuesday November 04, 2014 @04:40PM (#8559203)
In ISO C++ and GNU C you can also omit the 0:

    struct tm tm_struct = { };
Re:C Legacy Is Evil by JoeAltmaier on Tuesday November 04, 2014 @04:42PM (#8559216)
Does that work on char array members in the struct?
Re:C Legacy Is Evil by dezgeg on Tuesday November 04, 2014 @04:47PM (#8559253)
Yes, as far as I believe, this should always work in standard C89/C99. In the char array case, it works due to the brace elision rule in aggregates: assuming

    struct foo { char bar[3]; };
These declarations are equivalent:

    struct foo f1 = { 0, };
    struct foo f2 = { { 0, } };
Re:C Legacy Is Evil by readerrrr on Tuesday November 04, 2014 @04:45PM (#8559239)
In C, using: struct tm tm_struct = { 0 } ;, the rest of the struct including padding is initialized to zero bits.