Skip to content

Instantly share code, notes, and snippets.

@BYVoid
Created September 21, 2012 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BYVoid/3760736 to your computer and use it in GitHub Desktop.
Save BYVoid/3760736 to your computer and use it in GitHub Desktop.
Global variable in multiple files
int buf = 0;
void func() {
buf = 2;
/* Do something else */
}
#include <stdio.h>
int buf;
void func();
int main() {
buf = 1;
func();
printf("%d\n", buf);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment