/*******************************************************************************
ID: 3743990 • Letter: #
Question
/******************************************************************************* * List header files - do NOT use any other header files. Note that stdlib.h is * included in case you want to use any of the functions in there. However the * task can be achieved with stdio.h and string.h only. *******************************************************************************/ #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_time and struct flight 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 size =0; /******************************************************************************* * Function prototypes - do NOT change the given prototypes. However you may * define your own functions if required. *******************************************************************************/ void print_menu (void); void option(int i,int size,flight_t flights[MAX_NUM_FLIGHTS]) void addflights(int i,flight_flights[MAX_NUM_FLIGHTS]); void displayflights(int i,flight_flights[MAX_NUM_FLIGHTS]); void saveflightssavetodabase(flight_t flights[]); void loadflightsfromdatabase(flight_t flights[]); /******************************************************************************* * Main *******************************************************************************/ int main(void) { /* TODO */ int i =0; flight_t flights[MAX_NUM_FLIGHTS]; int optionnumber; char option2[MAX_FLIGHTCODE_LEN]; flight_t flights[MAX_NUM_FLIGHTS]; while(1) { print_menu(); scanf("%d",&optionnumber); option(optionnumber); } return 0; } thats my code, i could not compilec, can someone fix it for me?
Explanation / Answer
Mistake:
While calling function option(), you are passing only one argument where you define prototype with three arguments. I added parameters. You can changes according to your program.
Modified Code:
/******************************************************************************* * List header files - do NOT use any other header files. Note that stdlib.h is * included in case you want to use any of the functions in there. However the * task can be achieved with stdio.h and string.h only. *******************************************************************************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
/* 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_time and struct flight 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 size =0;
/******************************************************************************* * Function prototypes - do NOT change the given prototypes. However you may * define your own functions if required. *******************************************************************************/
void print_menu (void);
void option(int i,int size,flight_t flights[MAX_NUM_FLIGHTS]);
void addflights(int i,flight_t flights[MAX_NUM_FLIGHTS]);
void displayflights(int i,flight_t flights[MAX_NUM_FLIGHTS]);
void saveflightssavetodabase(flight_t flights[]);
void loadflightsfromdatabase(flight_t flights[]);
/******************************************************************************* * Main *******************************************************************************/
int main(void) {
/* TODO */
int i =0;
int optionnumber;
char option2[MAX_FLIGHTCODE_LEN];
flight_t flights[MAX_NUM_FLIGHTS];
while(1)
{
print_menu();
scanf("%d",&optionnumber);
option(optionnumber, MAX_NUM_FLIGHTS, flights);
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.