Skip to content

Instantly share code, notes, and snippets.

@only-entertainment
Created September 20, 2012 21:21
Show Gist options
  • Save only-entertainment/3758425 to your computer and use it in GitHub Desktop.
Save only-entertainment/3758425 to your computer and use it in GitHub Desktop.
Example of global scope but bad usage
#include <stdio.h>
int foo(int, int, int, int, int, int);
// Globally scoped
int a, b, c = 0;
int x = 10;
int d, e = 0;
int main(int argc, char * argv[])
{
foo(a, b, c, x, d, e);
}
int foo(int aa, int bb, int cc, int xx, int dd, int ee)
{
// Parameters are scoped to 'foo'
printf("Number: %d %d %d\n", aa, bb, cc);
scanf("%d %d %d", &aa, &bb, &cc);
dd = xx + aa + bb + cc;
ee = dd/4;
printf("Your number is: %d\n ", ee);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment