fork download
  1. // **************************************************
  2. // Function: testOfficerStructure
  3. //
  4. // Description: Declares Starfleet officer structures
  5. // and verifies compilation works
  6. //
  7. //
  8. // Parameters: none
  9. //
  10. //
  11. // Returns: 1 - successful execution
  12. //
  13. // ***************************************************
  14.  
  15. #include <stdio.h>
  16.  
  17.  
  18. // supporting structure for dates
  19. struct date {
  20. int day;
  21. int month;
  22. int year;
  23. };
  24.  
  25. // supporting structure for address
  26. struct address {
  27. char street[100];
  28. char city[50];
  29. char state[50];
  30. char zip[20];
  31. char planet[50];
  32. };
  33.  
  34. // supporting structure for ship information
  35. struct ship {
  36. char shipName[50];
  37. char nickname[50];
  38. };
  39.  
  40. // support of officer info
  41. struct officer {
  42.  
  43. char name[100];
  44.  
  45. char starFleetID[9];
  46.  
  47. struct date dateOfBirth;
  48. struct address addr;
  49.  
  50. char rank[100];
  51. struct date lastPromotionDate;
  52.  
  53. struct ship shipInfo;
  54.  
  55. float hourlyPay;
  56. char favoriteSaying[100];
  57. float startingStardate;
  58.  
  59. char maritalStatus[20];
  60. struct date graduationDate;
  61.  
  62. };
  63.  
  64.  
  65. // **************************************************
  66. // Function: testOfficerStructure
  67. //
  68. // Description: Declares an array of officer
  69. // structures and checks that the
  70. // structure setup works
  71. //
  72. //
  73. // Parameters: none
  74. //
  75. //
  76. // Returns: 1 - successful execution
  77. //
  78. // ***************************************************
  79.  
  80. int testOfficerStructure()
  81. {
  82. struct officer officers[100];
  83.  
  84. officers[0].starFleetID[0] = '0';
  85.  
  86. return 1;
  87.  
  88. } //testOfficerStructure
  89.  
  90.  
  91.  
  92. int main()
  93. {
  94. int result;
  95.  
  96. result = testOfficerStructure();
  97.  
  98. printf("Result: %d\n", result);
  99.  
  100. return 0;
  101. }
Success #stdin #stdout 0s 5316KB
stdin
// **************************************************
// Function: testOfficerStructure
//
// Description: Declares Starfleet officer structures
//              and verifies compilation works
//
//
// Parameters: none
//
//
// Returns: 1 - successful execution
//
// ***************************************************

int testOfficerStructure()
{

    // supporting structure for dates
    struct date {
        int day;
        int month;
        int year;
    };

    // supporting structure for address
    struct address {
        char street[100];
        char city[50];
        char state[50];
        char zip[20];
        char planet[50];
    };

    // supporting structure for ship information
    struct ship {
        char shipName[50];
        char nickname[50];
    };

    // support of officer info
    struct officer {

        char name[100];

        char starFleetID[9];

        struct date dateOfBirth;
        struct address addr;

        char rank[100];
        struct date lastPromotionDate;

        struct ship shipInfo;

        float hourlyPay;
        char favoriteSaying[100];
        float startingStardate;

        char maritalStatus[20];
        struct date graduationDate;

    };

    // array of officers
    struct officer officers[100];

    // simple check (program reached this point)
    return 1;

} //testOfficerStructure
stdout
Result: 1