I have seen source codes always having a typedef for a structure and using the same everywhere instead of using the structure name as “struct sname” etc directly?
What is the reason behind this? Are there any advantages in doing this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Its easier to read
Box b;thanstruct boxtype b;Advantage:
In the above
typedef, bothEntry&EntryPare defined apart fromstruct _entry.So,
EntryP firstentrycan be used in place ofstruct _entry *firstentryand is a little simpler to parse in mind.Note: Its not like structure names should be
typedefined, but evidently its easier to read. Also, use ofEntry *vsEntryPis totally user-dependent.