Skip to content
Related Articles

Related Articles

Improve Article

G-Fact 17

  • Difficulty Level : Basic
  • Last Updated : 02 Mar, 2013

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 fime




#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. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

My Personal Notes arrow_drop_up
Recommended Articles
Page :