Always store struct definitions and typedef definitions in header files

  • Example header file for the BankAccount data type:

     // Filename: bankaccount.h
     #ifndef bankaccount_h
     #define bankaccount_h
    
     struct BankAccount 
     {   
       int   ID;
       float balance;
     };
    
     typedef  struct BankAccount BankAccount_t;
    
     #endif 

  • C programs that wants to define BankAccount variables will use:

      #include "bankaccount.h"

    to obtain the struct BankAccount data type definition

DEMO: demo/C/set2/types.h + demo/C/set2/use-types.c