#include <stdio.h>
// Assuming the date, address, rankDetail, and officer structures are defined as before
struct date {
int day;
int month;
int year;
} ;
struct address {
char street[ 100 ] ;
char city[ 50 ] ;
char state[ 50 ] ;
int zipCode;
char planet[ 50 ] ;
} ;
struct rankDetail {
char rank[ 30 ] ;
struct date lastPromotionDate;
} ;
struct officer {
char name[ 50 ] ;
struct date dateOfBirth;
struct address homeAddress;
char ship[ 50 ] ;
} ;
// Function to read date from standard input
struct date readDate( ) {
struct date d;
scanf ( "%d/%d/%d" , & d.
month , & d.
day , & d.
year ) ; return d;
}
// Function to read address from standard input
struct address readAddress( ) {
struct address a;
scanf ( " %[^\n ]s" , a.
street ) ; // Read until newline is encountered scanf ( " %[^\n ]s" , a.
city ) ; scanf ( " %[^\n ]s" , a.
state ) ; scanf ( " %[^\n ]s" , a.
planet ) ; return a;
}
int main( ) {
struct officer o;
printf ( "Enter officer's name: " ) ; scanf ( " %[^\n ]s" , o.
name ) ; // Read string until newline is encountered
printf ( "Enter officer's date of birth (MM/DD/YYYY): " ) ; o.dateOfBirth = readDate( ) ;
printf ( "Enter officer's address in the format: street, city, state, zip code, planet\n " ) ; o.homeAddress = readAddress( ) ;
printf ( "Enter officer's ship: " ) ; scanf ( " %[^\n ]s" , o.
ship ) ;
// Printing to verify the input
printf ( "\n Officer's Name: %s\n " , o.
name ) ; printf ( "Date of Birth: %d/%d/%d\n " , o.
dateOfBirth .
month , o.
dateOfBirth .
day , o.
dateOfBirth .
year ) ; printf ( "Address: %s, %s, %s, %d, %s\n " , o.
homeAddress .
street , o.
homeAddress .
city , o.
homeAddress .
state , o.
homeAddress .
zipCode , o.
homeAddress .
planet ) ;
return 0 ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgovLyBBc3N1bWluZyB0aGUgZGF0ZSwgYWRkcmVzcywgcmFua0RldGFpbCwgYW5kIG9mZmljZXIgc3RydWN0dXJlcyBhcmUgZGVmaW5lZCBhcyBiZWZvcmUKCnN0cnVjdCBkYXRlIHsKICAgIGlud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