| Start |
|---|
| Typedef for Structures and Unions You can give alias names to a Compared to the traditional way of declaring structs, programmers wouldn't need to have Note that the name or: The use of a A structure similar to this can be used to analyze the bytes that make up a |
Simple Uses of Typedef For giving short names to a data typeInstead of: one can use This reduces the amount of typing needed if the type is used many times in the program. Improving portabilityThe attributes of data types vary across different architectures. For example, an In one implementation, let the size of For the program to run in the first implementation, all the To avoid this, one can use Then, only the The To specify a usage or to improve readabilityIf a set of data has a particular purpose, one can use |
| Typedef for Function Pointers We can use Now we can use a This creates a type, named Then to call the function pointed to by the function pointer variable: Thus the If you are using a function that takes a function pointer as a parameter without a function pointer type defined the function definition would be, However, with the Likewise functions can return function pointers and again, the use of a A classic example is the That's a function that takes two arguments — an If we defined a type then we could declare On the whole, this is easier to understand (even though the C standard did not elect to define a type to do the job). The Although using Syntax
RemarksDisadvantages of Typedef
Disadvantages of Typedef Structs Also, Consider: With such a definition, not using Typedef vs #define
|
Read Article
https://develop.horje.com/learn/1434/reference