typedef and Structures


We have seen that a structure object can be declared by using the keyword struct followed by the tag-name of the defined structure type and the identifier name of the object to be declared. The usage of the keyword struct while declaring a structure object sometimes proves to be a bit inconvenient. We have seen that the storage class specifier typedef can be used for creating syntactically convenient names (i.e. aliases). Thus, it can be used to create an alias for the defined structure type so that the keywordstruct is not required repeatedly to declare the structure objects. The piece of code in Program 25 illustrates the use of the typedefstorage class specifier along with structures.

Program 25. A program that illustrates the use of the storage class specifier typedef to name and rename a structure type

Post a Comment

Previous Post Next Post