G-Fact 17

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

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

5

But the following program fails with compiler error.

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


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


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.