codegurukool.com · Free coding tutorials & online compiler

Home › C Tutorial › C storage classes

C storage classes

auto, static, extern, register.

A static local keeps its value between calls. extern refers to a variable defined in another file.

Example code

#include <stdio.h>
void count() { static int n = 0; n++; printf("%d ", n); }
int main() {
  count(); count(); count();
  printf("\n");
  return 0;
}

Run this code in the online editor

← C macrosC bitwise operators →