Consider the following:
struct Foo
{
char c;
int i;
};
void Bar(void)
{
struct Foo f = {0}; // use zero initializer
// do some stuff
f = (struct Foo) {'h', 1}; // copy different data into f, is this dangerous?
}
Would the cast above be considered dangerous? Is this good style?
It’s not a matter of style; that code won’t compile without the
(struct Foo). It’s not a cast, it’s part of the syntax for a C99 feature known as a compound literal.