You can change the value of a global variable and after the change, everywhere in the code, this new value is stored in the global variable.
Your code has many syntax errors, misspelled variable names, and an unusual logic to call the main function from other functions. Instead, I'll provide my own example below.
Static and global variables
In C, global variables are declared outside of functions (without the static keyword). Anyone in the code can see their values (but other files may need to reference them with extern keyword).
Static variables inside functions are initialized only once and then keep their values within executions of the same function -- without getting re-initialised. Remove the static keyword, and see how the execution changes.
Here's the example code below I promised:
#include <stdio.h>
int functionCallCount = 0;
void PrintFunctionCallCount()
{
printf("functionCallCount: %d\n", functionCallCount);
}
void Foo()
{
static int fooCount = 0;
functionCallCount++;
fooCount++;
printf("Foo has been called: %d times\n", fooCount);
}
void Bar()
{
functionCallCount++;
printf("Bar has been called.\n");
}
int main()
{
Foo();
Bar();
Foo();
Bar();
Foo();
PrintFunctionCallCount();
return 0;
}
Play around and see how the execution changes if you turn static variables into regular variables.
Have fun!