home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / misc / lib / r_la4_02 / enums.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-01-25  |  1.0 KB  |  37 lines

  1. /* ENUMS.C - From page 545 of "Microsoft C Programming for      */
  2. /* the IBM" by Robert Lafore. This program is an example of     */
  3. /* using enumerated data types. This program gives an error:    */
  4. /* Fatal error:L1101 Invalid object module when linking.        */
  5. /* In Quick C Programmers Guide user is requested to contact    */
  6. /* Microsoft.                                                   */
  7. /****************************************************************/
  8.  
  9. main()
  10. {
  11. enum empcats {
  12.    management,
  13.    research,
  14.    clerical,
  15.    sales
  16. };
  17. struct {
  18.    char name[30];
  19.    float salary;
  20.    enum empcats category;
  21. } employee;
  22.  
  23.    strcpy(employee.name, "Benjamin Franklin");
  24.    employee.salary = 118.50;
  25.    employee.category = research;
  26.  
  27.    printf("\n\nName = %s", employee.name);
  28.    printf("\nSalary = %6.2f", employee.salary);
  29.    printf("\nCategory = %d", employee.category);
  30.  
  31.    if(employee.category == clerical)
  32.       printf("\n\nEmployee category is clerical.");
  33.    else
  34.       printf("\nEmployee category is not clerical.");
  35. }
  36.  
  37.