Okay, I made a basic program detailing departures from 2 airports.
Code:
#include <stdio.h>
int input;
struct Reno_Airport {
char FNewYork[60];
char FSacramento[60];
char FMontreal[60];
} Reno_Airport = {
"New York, 3:00",
"Sacramento, 1:23",
"Cancelled."
};
struct Copenhagen_Airport {
char FMoscow[60];
char FCairo[60];
} Copenhagen_Airport = {
"Moscow, 17:30",
"Cairo, 23:34",
};
main()
{
printf("Enter Airport: 1=Reno, 2=Copenhagen ");
scanf("%d",&input);
switch (input) {
case 1:
printf("Departures: %c, %c, %c",FNewYork, FSacramento, FMontreal);
break;
case 2:
printf("Departures: %c, %c",FMoscow, FCairo);
break;
}
}
By the way, I already tried putting in Reno_Airport.FNewYork instead of FNewYork, and the same for Sacramento and Montreal, as well as copenhagen for Moscow and Cairo, so that's not it. When I run it with the structure/variable name in front of the characters it just gives me strange characters as an output.
So, how do I get fields from structures and print them out?