1. ## Question???

I have a question. The instructions given from the professor states to do the following:
Declare an array of five elements of type FLIGHT. Write a function that initializes the array(using structures).

My original Structure:

struct FLIGHT
{
long flightnum;
long Date;
char departcode
ete......
};

Declare an array of five elemens of type FLIGHT:
I did this in main,

FLIGHT numof[5];
getnum(numof[5]);//calling funtion

Write a function that initializes the array.
assuming I have written the funtion prototype and I have called the function in main, I wrote the following funtion per these intructions:

int getnum(int flightinfo)
{
FLIGHT numof[5]={1111}{1112}{1113}{1114}

Am I doing this correctly? Wouldn't the initialization only need the first element of the structure?

2. int getnum(int flightinfo)
{
FLIGHT numof[5]={1111}{1112}{1113}{1114}

You can't define data in a routine you call and be able to use it from the calling method unless you put it on the heap with a new;

i'd change the getnum name to

InitializeFlight( FLIGHT * pFlight, int nQty )
Use InitializeFlight to iterative initialize the array based on the quantity of FLIGHT objects.

and call it with

InitializeFlight( numof , ( sizeof( numof ) / sizeof( numof[0]) ) )

3. FLIGHT numof[5]={1111}{1112}{1113}{1114}
I believe this would initialize a 5 dimensional array. What you're looking for is:
FLIGHT numof[5] = {11111, 11112, 11113, 11114}
You're also leaving one array element undefined. You put 5 elements in a five element array. They are subscripted from 0 to 4, but there are 5 elements in the array.
Or, I'm going buggy from looking at too much code.

4. Code:
```struct FLIGHT
{
long flightnum;
long Date;
char departcode
};

InitializeFlight(struct FLIGHT, int);

int main()
{
struct FLIGHT numof[5];
InitializeFlight( numof , ( sizeof( numof ) / sizeof( numof[0]) ) )
...
return 0;
}

InitializeFlight(struct FLIGHT fl, int size)
{
for(int i=0;i < size; i++)
{
fl[i].flightnum = 1111;
fl[i].Date = 2222;
fl[i].departcode = 'x';
}
}```
This is more or less what you want but you are likely wanting to initalize the structure with data from a datafile. Anyways this is the format. I used some code from the other suggestions.