Initialization is different fromassignment. For structure variable, I can set its original value with a {}.
But this method is valid only once, and must be at the same time---when it is defined.
After it is defined, if I want to change one or more its members' value, I can't use the same method:{},
and mustn't do that. The only valid method is assign them one by one. Below is an example:
struct statistic gsta;
void echo_init(void)
{
gsta =
{
.nsend = 0,
.nrecv = 0,
...
};
}
very very bad!!! Don't do that like me again.
But this method is valid only once, and must be at the same time---when it is defined.
After it is defined, if I want to change one or more its members' value, I can't use the same method:{},
and mustn't do that. The only valid method is assign them one by one. Below is an example:
struct statistic gsta;
void echo_init(void)
{
gsta =
{
.nsend = 0,
.nrecv = 0,
...
};
}
very very bad!!! Don't do that like me again.