When in doubt about small things like this in C, I like to write a quick program to test the problem (it generally saves tons more time than posting on a forum):
Code:
#include <stdio.h>
void test_static(int bar)
{
static int foo = 0;
printf("foo is: %d\n", foo);
foo = bar;
printf("foo is: %d\n", foo);
}
int main(void)
{
test_static(2);
test_static(100);
return 0;
}
The output from that is:
Code:
foo is: 0
foo is: 2
foo is: 2
foo is: 100
I guess that answers your question
BTW, setting a static variable to zero is unnecessary, since K&R's book indicates that static variables get automatically initialized to zero.