The typedef keyword is used to introduce synonyms for types which are intrinsic types (int, float, etc.) or where declared some other way (structs, classes). The new name becomes equivalent to the type you wanted.
-
-
struct terms {
-
// some fields
-
};
-
-
// Declare a pointer of struct terms.
-
struct terms *termptr;
-
Now we accomplish the same thing using a typedef.
-
-
struct terms {
-
// some fields
-
};
-
-
typedef struct terms *express;
-
-
// The decleration of "termptr" is equivalent to our previous example
-
express termptr;
-
I generally think it is a poor idea to introduce a new type name for pointer types that don't explicitly indicate in the type name that it is a pointer type. In the last example I think it would be better to have named the new type "p_express", or "express_ptr", or "terms_ptr", or "p_terms."