Nothing too much to exaplin here, but let's walk you through it.
Global variables are those variables which any function in a source file can use, whereas local variables are confined within the function they were declared in. (Side note: in order to use a variable in another source file as well, declare it with an extern keyword infront of it. ex: extern int myint; )
prototypes are telling the compiler exactly what sorts of parameters a function takes so it knows whether you're using it wrong in your source. an alternative to doing that is to define the function before your main code, so you could have either:
Code:
int myfunc(int);
int main(void)
{
/*code*/
}
int myfunc(int counter)
{
return counter++;
}
or
Code:
int myfunc(int counter)
{
return counter++;
}
int main(void)
{
/*code...*/
}
And that's pretty much all there is to it.