You can use extern keyword along with function declaration as well, but that's a redundant operation since functions have external linkage by default. ie; They can be accessed globally from other places.
'Typedef' Qualifier
'typedef' is not a storage class specifier, but it allows us to give an alias (new name) to existing data types (built-in or user defined datatypes). Sytax of 'typedef' is as given below,
typedef data_type alias;
Let's consider the following example
typedef int number;
Here, we've given an alias to data type 'int' which is 'number'. So now we can use 'number' as a type in variable declaration and definition to hold an integer values. By creating an alias, we can use it as given below
number first, second;
It means 'first' and 'second' are of the 'number' data type which in turn is an integer. So, 'first' and 'second' are also integers.
Summary of Storage Class Specifiers
Table given below summarizes the storage location, initial default value, scope and life time of different storage class specifiers
Storage Class | Space Allocated in | Default Initial Value | Scope | Life |
---|---|---|---|---|
auto | Memory | Garbage | Local Scope | Alive within the declared code block |
register | CPU Register | Garbage | Local Scope | Alive within the declared code block |
static | Memory | 0 | Local Scope | Value retained between invocations |
extern | Memory | 0 | Global Scope | Alive till program exit |
No comments:
Post a Comment