L
lovecreatesbea...
Thad said:No, initializations of auto variables are performed on encountering the
declarations in the control flow. I don't have H&S to refer to. Maybe
they meant that an initialization of static variables would only occur
once, not each invocation.
Thad, thanks for the clarification of the usage of the initialization
of auto variables.
I wouldn't do that, but would instead clearly document the parameter
requirements and return value. I would also add more to make the
program a little easier to read and use my own brace rules:
while ((*d++ = *s) != '\0') {
while (*s++ == ' ' && *s == ' ') n++;
}
return n;
}
The explicit comparison with '\0' makes the intent clearer and
eliminates a warning from some compilers. The unneeded braces is my own
rule to use braces if the statement following a for, while, if, or else
is on a following line (otherwise I have forgotten that there is no
brace and added another indented line below the original -- oops!).
Regards