OK I have modified my code to thus...
Code:
#define _CRT_SECURE_NO_DEPRECATE
#include "airline.h"
void display_menu()
{
printf( "=========================================================\n");
printf( " To chose a function, enter its letter label:\n\n");
printf( "a) Show assigned seats with passenger names\n");
printf( "b) Show list of empty seats\n");
printf( "c) Assign a customer to a seat\n");
printf( "d) Edit customer details, for a specific seat\n");
printf( "e) Delete a seat assignment\n");
printf( "f) Quit\n");
printf( "=========================================================\n");
}
void options(pass* p)
{
int j=0;
char choice;
for(;;)
{
scanf("%c", &choice);
switch (tolower(choice))
{
case 'a':
for(j=0; j<LIMIT; j++)
{
disp_assigned(p, j);
}
break;
case 'b':
//empty_seat();
break; case 'c':
//allocate_seat();
break; case 'd':
//edit_details();
break; case 'e':
//delete_seat();
break; case 'f':
exit(1);
break;
default:
printf( "Invalid option, please try again:\n"); fflush(stdin);
break;
}
}
}
void disp_assigned(pass *cust, int i)
{
if (cust[i].flag = 0)
printf("Seat %d is unassigned", i+1);
else
printf( "\nThe details of passenger %d are:\n", i+1);
printf( "Name: %s %s\n", cust[i].first, cust[i].last);
}
int main()
{
pass customers[LIMIT]; // An array of 14 (LIMIT) structures
int i;
for(i=0; i<LIMIT; i++)
{
customers[i].row = (i/2) + 1; /* rows from 1 to 7 */
customers[i].label = (i%2)?'B':'A'; /* odd i B, even A */
customers[i].flag = 0; /* seat empty */
strcpy(customers[i].first, "Not ");
strcpy(customers[i].last, "Assigned");
}
display_menu();
options(customers);
}
header file...
Code:
/* airline.h */
#define _CRT_SECURE_NO_DEPRECATE
#include<stdio.h>
#include<string.h>
#define NAME 20
#define LIMIT 14
struct passenger
{
int row; /* from 1 to 7 */
char label; /* A or B */
int flag; //Use as a boolean - 1 if seat taken, 0 if not takes
char first[NAME];
char last[NAME];
};
typedef struct passenger pass;
/* function prototypes */
void display_menu(void);
void options(pass* p);
void disp_assigned(pass* cust, int j);
This piece of code isnt working... its not getting the value what it should be. How do i rectify this?
Code:
if (cust[i].flag = 0)
thanks