Open In App

GFact | Storage class of a variable

Storage class of a variable determines whether the item has a global or local lifetime. In C, typedef is considered as a storage class like other storage classes (auto, register, static and extern), nevertheless the purpose of typedef is to assign alternative names to existing types. For example, the following program compiles and runs fine 




#include <stdio.h>
int main()
{
  typedef int points;
  points x = 5;
  printf("%d ", x);
  return 0;
}

Output:



5

But the following program fails with compiler error. 




#include <stdio.h>
int main()
{
  typedef static int points;
  points x;
  return 0;
}

Output:



Compiler Error: multiple storage classes in declaration specifiers

See this quiz for practice on storage class and type specifiers.

Article Tags :