Mega Code Archive

 
Categories / C++ Tutorial / Language Basics
 

Global variables are known throughout the entire program and may be used by any piece of code

#include <stdio.h>             void func1(void), func2(void);          int count;         main(void)    {      count = 100;      func1();      return 0;  }          void func1(void)    {      int temp;            temp = count;      func2();      printf("count is %d", count); /* will print 100 */    }          void func2(void)    {      int count;            for(count=1; count<10; count++)        putchar('.');    }