I'm trying to create an array of structs but keep getting this error. can you please advise?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MODEL_LENGTH 4
#define NUM_OF_DESTINATIONS 8
#define MAX_DESTINATIONS_WORD_LENGTH 12
#define NUM_OF_PLANES 3
typedef struct
{
char p_model[MODEL_LENGTH];
char p_destinations[NUM_OF_DESTINATIONS][MAX_DESTINATIONS_WORD_LENGTH];
} airplane;
airplane a_737 = { "737", {"Larnaca", "Athens", "Budapest", "Zurich",
"London", "Paris", "Rome"} };
airplane b_747 = { "747", {"London", "New York", "Bangkok"} };
airplane c_787 = { "787", {"London", "New York", "Los Angeles", "Hong
Kong", "Miami"} };
airplane planes_arr[NUM_OF_PLANES] = { a_737, b_747, c_787 };
I used to have numbers instead of #define, after reading posts I changed it but I still don't understand what's wrong here.
update:
I tried changing the array to an "airplane *planes_arr[]".
I tried typing:
airplane *a_ptr = &a_737;
and tried to put "a_ptr" in the array and I keep getting the same error.
now, i changed to this:
airplane *planes_arr[NUM_OF_PLANES] = { &a_737, &b_747, &c_787};
and no error showed.
can I please get an explanation on the topic?