Open In App

GFact | Storage class of a variable

Last Updated : 17 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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 

C




#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. 

C




#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.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads