#include <stdio.h>
void func() {
static int x = 0; // x is initialized only once across three calls of
// func()
printf("%d\n", x); // outputs the value of x
x = x + 1;
}
int main(int argc, char * const argv[]) {
func(); // prints 0
func(); // prints 1
func(); // prints 2
// Here I want to reinitialize x value to 0, how to do that ? <-- this line
return 0;
}
In the above code, after calling func() 3 times I want to re-initialize x
to zero. Is there any method to reinitialize it to 0?