What I would really like to do is enter a name(1). Just one name at a time. have it become part of a char array.Ex.
Code:
char passarray [10][30]
but at the same time assign it a value in an int array. Ex.
Code:
int seatarray [6][2]
I got a big hot mess here.....
Code:
#include <stdio.h> // standard rules#include<string.h>
#include <stdlib.h>
void runmenu (void);
void getnames (void);
void getseat(void);
void getemptylistseat(void);
void getsortlastname(void);
void getdeletenames(void);
void printInstructions(void);
int getOption(void);
int option;
int x,y;
char passenger[10][30],temp[12];
int array[6][2];
int main (void) // program starts execution
{
printInstructions();
runmenu();
return 0;
}
void runmenu (void)
{
do{
printf("\n Select your function, then enter the information requested.\n\n"); // option for functions
printf(" 1. Show the number of empty seats\n");
printf(" 2. Show a list of empty seats\n");
printf(" 3. Show by last name an alphabetical list of assigned seats\n");
printf(" 4. Assign a customer to a seat\n");
printf(" 5. Delete a seat assignment\n");
printf(" 6. QUIT\n");
option = getOption();
switch(option)
{
case 1:
getseat();
break;
case 2:
getemptylistseat();
break;
case 3:
getsortlastname();
break;
case 4:
getnames();
break;
case 5:
getdeletenames();
break;
case 6:
printf("Quitting, Goodbye\n\n\n");
break;
default:
printf("Invalid entry");
}
}while(option != 6);
}
int getOption(void)
{
int option;
scanf("%d", &option);
system ( "cls" );
return option;
}
void getdeletenames(void)
{
printf("\n\n\nWhat passenger would you like to delete?\n\n\n");
scanf("%s", passenger[x]);
}
void getseat(void)
{
printf("\n\n\n\this function is suposed to show number of empty seats %p.\n\n\n",array);
}
void getsortlastname(void)
{
printf("\n\n\nThis function is susposed to sort by last name and show assigned seat\n\n");
for(x=0;x<9;x++)
{
for(y=0;y<9;y++)
{
if(strcmp(passenger[y],passenger[y+1])>0)
{
strcpy(temp,passenger[y]);
strcpy(passenger[y],passenger[y+1]);
strcpy(passenger[y+1],temp);
}
}
}
printf("The names sorted by Surname are\n");
for(x=0;x<10;x++)
printf("\n%s is in seat %d",passenger[x],array);
printf("\n\n");
}
void getnames (void)
{
getemptylistseat();
printf("\n\nEnter the passengers name: \n\n example: Smith,Bob\n\n");
for(x=0;x<1;x++)
{
scanf("%s",passenger[x]);
printf("Enter Seat Number");
scanf("%d",array);
}
printf("\n\n");
}
void getemptylistseat (void)
{
for ( x = 0; x < 2; x++ ) {
for ( y = 0; y < 6; y++ )
array[0][0] =1;/* Set each element to a value */
array[0][1] =2;
array[1][0] =3;
array[1][1] =4;
array[2][0] =5;
array[2][1] =6;
array[3][0] =7;
array[3][1] =8;
array[4][0] =9;
array[4][1] =10;
array[5][0] =11;
array[5][1] =12;
}
printf( "Seats :\n" );
for ( x = 0; x < 6;x++ ) {
for ( y = 0; y < 2; y++ )
{
printf( "[%d][%d] = %d ", x, y, array[x][y] );
}
printf( "\n" );
}
getchar();
}
void printInstructions (void)
{
printf("********************************************************************************");
printf("** The Cape Fear Airlines has one plane with a seating capacity of 12. **** It makes one flight daily. This program that will allow the user to enter **** a list of first and last names then reserve their seat accordingly. **********************************************************************************");
}
Basically I want to take the first part and put it into the last part
Code:
void getnames (void){
getemptylistseat();
printf("\n\nEnter the passengers name: \n\n example: Smith,Bob\n\n");
for(x=0;x<1;x++)
{
scanf("%s",passenger[x]);
printf("Enter Seat Number");
scanf("%d",array);
}
printf("\n\n");
}
void getemptylistseat (void)
{
for ( x = 0; x < 2; x++ ) {
for ( y = 0; y < 6; y++ )
array[0][0] =1;/* Set each element to a value */
array[0][1] =2;
array[1][0] =3;
array[1][1] =4;
array[2][0] =5;
array[2][1] =6;
array[3][0] =7;
array[3][1] =8;
array[4][0] =9;
array[4][1] =10;
array[5][0] =11;
array[5][1] =12;
}
printf( "Seats :\n" );
for ( x = 0; x < 6;x++ ) {
for ( y = 0; y < 2; y++ )
{
printf( "[%d][%d] = %d ", x, y, array[x][y] );
}
printf( "\n" );
}
getchar();