Mega Code Archive

 
Categories / C / Code Snippets
 

Use global variable in function

#include <stdio.h> int max; /* a global variable */ void f(void) { int j; for(j=0; j<max; j++) printf("%d ", j); } int main(void) { max = 10; f(); return 0; }