9.3. static

static variables are variables that don't get deleted when they fall out of scope, they are permanent and retain their value between calls to the function. Here's an example:

Example 9-1. list_squares.c

#include <stdio.h>

int get_next_square(void);

  int i;

  for(i = 0; i < 10; i++)
    printf("%6d\n", get_next_square());

  printf("and %6d\n", get_next_square());

  return 0;

  static int count = 1;

  count += 1;

  return count * count;
This will list the squares of the numbers from zero to ten. Zero to nine are printed by the loop and the square of ten is printed afterwards just to show it still has it's value.