Question: #include #include #include /******************************************************************************* * List preprocessing directives - you may define your own. *******************************************************************************/ #define MAX_FLIGHTCODE_LEN 6 #define MAX_CITYCODE_LEN 3 #define MAX_NUM_FLIGHTS 5 #define

#include

#include

#include

/*******************************************************************************

* List preprocessing directives - you may define your own.

*******************************************************************************/

#define MAX_FLIGHTCODE_LEN 6

#define MAX_CITYCODE_LEN 3

#define MAX_NUM_FLIGHTS 5

#define DB_NAME "database"

/*******************************************************************************

* List structs - you may define struct date and struct student only. Each

* struct definition should have only the fields mentioned in the assignment

* description.

*******************************************************************************/

struct date_time

{

int month;

int day;

int hour;

int minute;

};

typedef struct date_time date_time_t;

struct flight

{

char flightcode[MAX_FLIGHTCODE_LEN+1];

date_time_t departure_dt;

char arrival_city [MAX_CITYCODE_LEN+1];

date_time_t arrival_t;

};

typedef struct flight flight_t;

int main()

{

char second_choice[MAX_CITYCODE_LEN+1];

int i=0;

printf("Enter arrival city code or enter * to show all destinations> ");

scanf("%s",second_choice);

if(i==0)

{

printf("No flights ");

}

else if(strcmp(second_choice,"*")==0){

while(i>0)

{

printf("something")

i--;

printf(" ");

}

}

else

{

// some code to compare second_choice to the " char arrival_city [MAX_CITYCODE_LEN+1] " member of structure flight_t for every flight_t type structure in the fligths array.

}

}

My task was to generate an array of structures called " flights ". I have managed to create the array and it contains " i " number of flights(the variable i indicates the number of structures stored in the array called flights). The code i have posted is my second task. This task requires me to get an input from the user(I have called this second_choice) and use this input to dispay either one of two things. One option is if the user enters " * ", then "something" is printed, i have managed to do this part. The other option is if the user enters a string, for this case i need the program to compare this string to the arrival_city member of each structure in the flights array. if the string comparison finds a match, i need the program to print out which structure in the array had the arrival_city equal to the second_choice. If there are no matches i need the program to print out "no flights". I am really struggling with this, so any help would be appreciated.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!