Solution for Exercise 16-3

ex1603

#include <stdio.h>

typedef int stinky;

stinky main()
{
    stinky a = 2;

    printf("Everyone knows that ");
    printf("%d + %d = %d\n",a,a,a+a);
    return(0);
}

Output

Everyone knows that 2 + 2 = 4

Notes

* You can see better examples of typedef by perusing the various header files that came with the compiler. typedef is frequently used to name specific variable types used by functions prototyped within the header file. The typedef allows the variable type to be consistent, but also to change if need by.

* For example, the time_t data type is a typedef created in the time.h header file. It could be a long int, for example. Regardless, if the underlying data type changes in the future, your code remains compatible providing it uses the time_t data type.