venky said:
I am facing problem with typedef, can you explain in terms of real
time use of typdef?
First, note that "real time" has a special meaning in the computer field
that I don't think you intended here.
Secondly, note that typedef is a spectacularly bad word choice since it
doesn't define a type, rather it provides a new name, a synonym, for an
existing type. Once the typedef has been seen by the compiler you can use
either the old name or the new name for the same type.
Two dominant uses come to mind. One is to hide or encapsulate the
complexity of a complicated type, for example the pointer to a function is
often a rather nasty looking thing. Pointers to functions are typically
encountered in more or less advanced work, but beginners can encounter them,
for example, in the parameter list for bsearch and qsort in <stdlib.h>.
The other use is to minimize typing, a use frowned upon by many. For
example:
typedef unsigned char UC.
In the sequel you can write:
UC ch;
It makes virtually no sense for a single char, of course.
When you prefix a variable declaration with "typedef" the variable therein
is "promoted" to a type. I like to capitalize, at least the initial letter,
of types.