The following blocks are outside of main() and before each function (global scope)
1st block:
struct flight{ int number; int capacity; int passengers; };
With this you can create an array, pointer, variable, as opposed to writing }var ; (which defines only one variable of this custom data type (struct flight ))
Second block:
typedef struct flight{ int number; int capacity; int passengers; }flight;
Announcing this creates a flight data type without having to write struct flight all the time
My question is, why does typedef need a flight to be written a second time at the end of the block?
which is a bit confusing (it only looks like a variable of this data type)
c struct definition typedef
hitter
source share