Static Variables VS Pointers
Below is the sample code that I am working with. In the tutorial that relates to this example the author is explaining the usage of static variables as it relates to variable scope.
Code:
#include <stdio.h>
void func1(void);
main()
{
int count;
for (count = 0; count < 20; count++)
{
printf("At iteration %d: ", count);
func1();
}
return 0;
}
void func1(void)
{
static int x = 0;
int y = 0;
printf("x = %d, y = %d\n", x++, y++);
}
What the code does is understood, my question is: should I rather send a pointer variable to the function or use a static variable? Is this just a rudimentary example, different methods to accomplish the same task, or something different altogether?