struct personalInfo
{
char name[ 50 ] ;
char dateOfBirth[ 50 ] ;
char address[ 150 ] ;
char martialStatus[ 50 ] ;
char nickname[ 50 ] ;
char favoriteSaying[ 100 ] ;
} ;
struct employDates{
char lastPromotionDate[ 50 ] ;
float startingStarDate;
char starfleetGradDate[ 50 ] ;
} ;
struct otherEmployInfo{
char rank[ 50 ] ;
char ship[ 50 ] ;
char starfleetID[ 50 ] ;
float hourlyPay;
} ;
struct officer
{
struct personalInfo infoPersonal;
struct employDates infoDates;
struct otherEmployInfo infoOtherEmploy;
} ;
#include <stdio.h>
int main( void ) {
//Declare an array of structures
struct officer arrayOfficers[ 2 ] = {
{ { "Mr. James Tiberius Kirk" , "March 22, 2233" , "23 Falling Rock, Riverside, Iowa 52327-0021 Planet Earth" , " Single" , " Jim" , "Bones???" } } ,
{ { " April 12, 2224 " , 41153.7 , "June 23, 2212" } }
}
; // Given details for two officers for this question so I am declaring an array of size 2 in this case
// arrayOfficers[0].infoPersonal={
// .name="Mr. James Tiberius Kirk",
// .dateOfBirth="March 22, 2233",
// .address="23 Falling Rock, Riverside, Iowa 52327-0021 Planet Earth"
// }
// struct officer person1 = { "Mr. James Tiberius Kirk", "March 22, 2233", "23 Falling Rock, Riverside, Iowa 52327-0021 Planet Earth"," Single"," Jim","Bones???",
// " April 12, 2224 ", 41153.7, "June 23, 2212"};
// Print the initialized structure
printf ( "Name: %s\n " , arrayOfficers
[ 0 ] .
infoPersonal .
name ) ; printf ( "Date of Birth: %s\n " , arrayOfficers
[ 0 ] .
infoPersonal .
dateOfBirth ) ; printf ( "Address: %s\n " , arrayOfficers
[ 0 ] .
infoPersonal .
address ) ; printf ( "Martial Status: %s\n " , arrayOfficers
[ 0 ] .
infoPersonal .
martialStatus ) ; printf ( "Nickname: %s\n " , arrayOfficers
[ 0 ] .
infoPersonal .
nickname ) ; printf ( "Favorite Saying: %s\n " , arrayOfficers
[ 0 ] .
infoPersonal .
favoriteSaying ) ; printf ( "Last Promotion Date: %s\n " , arrayOfficers
[ 0 ] .
infoDates .
lastPromotionDate ) ; printf ( "Starting Star Date: %0.1f\n " , arrayOfficers
[ 0 ] .
infoDates .
startingStarDate ) ; printf ( "Star Fleet Grad Date: %s\n " , arrayOfficers
[ 0 ] .
infoDates .
starfleetGradDate ) ;
return 0 ;
}
c3RydWN0IHBlcnNvbmFsSW5mbwp7CiAgICBjaGFyIG5hbWVbNTBdOwogICAgY2hhciBkYXRlT2ZCaXJ0aFs1MF07CiAgICBjaGFyIGFkZHJlc3NbMTUwXTsKICAgIGNoYXIgbWFydGlhbFN0YXR1c1s1MF07CiAgICBjaGFyIG5pY2tuYW1lWzUwXTsKICAgIGNoYXIgZmF2b3JpdGVTYXlpbmdbMTAwXTsKCn07CgpzdHJ1Y3QgZW1wbG95RGF0ZXN7CiAgICBjaGFyIGxhc3RQcm9tb3Rpb25EYXRlWzUwXTsKICAgIGZsb2F0IHN0YXJ0aW5nU3RhckRhdGU7CiAgICBjaGFyIHN0YXJmbGVldEdyYWREYXRlWzUwXTsKCn07CgpzdHJ1Y3Qgb3RoZXJFbXBsb3lJbmZvewogICAgY2hhciByYW5rWzUwXTsKICAgIGNoYXIgc2hpcFs1MF07CiAgICBjaGFyIHN0YXJmbGVldElEWzUwXTsKICAgIGZsb2F0IGhvdXJseVBheTsKCn07CgpzdHJ1Y3Qgb2ZmaWNlcgp7CiAgICBzdHJ1Y3QgcGVyc29uYWxJbmZvIGluZm9QZXJzb25hbDsKICAgIHN0cnVjdCBlbXBsb3lEYXRlcyBpbmZvRGF0ZXM7CiAgICBzdHJ1Y3Qgb3RoZXJFbXBsb3lJbmZvIGluZm9PdGhlckVtcGxveTsKfTsKCiNpbmNsdWRlIDxzdGRpby5oPgoKaW50IG1haW4odm9pZCkgewoKICAgIC8vRGVjbGFyZSBhbiBhcnJheSBvZiBzdHJ1Y3R1cmVzCiAgICBzdHJ1Y3Qgb2ZmaWNlciBhcnJheU9mZmljZXJzWzJdPXsKICAgICAgICB7eyJNci4gSmFtZX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