
/************************************************************************
 *
 * Purpose: Demonstrate global and internal variables
 *
 ************************************************************************/
#include <stdio.h>

int counter = 0, counter1 = 0;			
                     /* global because we are outside 
                   all blocks.			*/
char ch[50];

int func(void);

FILE *fp,*fw;

main()
{
  ++counter;		/* global because it has not been
			   declared within this block	*/
  printf("counter is %2d before the call to func\n", counter);

fp=fopen("in","r");

  func();		/* call a function.		*/
  func();		/* call a function.		*/


  printf("counter is %2d after the call to func\n", counter);

fprintf(fw,"%d %s",counter1,ch);
fclose(fw);
fclose(fp);
}

int func(void)
{
  int counter = 10;	/* local.			*/
  printf("counter but mistyped is %2d within func\n", counter++);

fw=fopen("out","w");
fscanf(fp,"%d %s",&counter1,&ch);

}
