I can't make my program ignore input with extra spacing, it only gives up error.

Hi everyone, I'm writing an airline seating program and they demand that you should be able to write an entire line at once.
I.E. The input 3a y 3k y 3b
Now if I do this step by step in my program it works ,but they won't accept it unless I can write it all in on one go.

My second problem is that they want my code to also be able to read an input like 3 a, 3 b and etc.
I don't know how to do these things and I've been trying, even re-written my code several times to adjust to these demands.
Here's my code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include <iostream>
#include<cctype>
#include <ctype.h>
#include <iomanip>
using namespace std;

void ArrayMaking(char PlaneSeat[7][4])
{
    for (int i = 0 ; i < 7 ; i++ )
        for (int j = 0 ; j < 4 ; j++)
            PlaneSeat[i] [j] = 'A' + j;

}
void print(char PlaneSeat[7][4])
{


    for (int i = 0 ; i < 7; i++)
    {
        cout  <<  i + 1 << ' ' << " ";

        for (int j = 0 ;  j< 4; j++)
        {
            if (j == 2 )
            {
                cout << " ";
            }
            cout << " " <<  PlaneSeat[i][j] ;
        }
        cout << endl;
    }
cout << endl;
}
void print2(char PlaneSeat[7][4])
{


    for (int i = 0 ; i < 7; i++)
    {
        cout  <<  i + 1 << ' ' << " ";

        for (int j = 0 ;  j< 4; j++)
        {
            if (j == 2 )
            {
                cout << " ";
            }
            cout << " " <<  PlaneSeat[i][j] ;
        }
        cout << endl;
    }

}

void getInput(char *c)
{

    while(!isdigit(c[0] && !isalpha(c[1])))
    {   cout << "Seat number:";
        c[0] = cin.get();
        c[1] = cin.get();
        cin.ignore(100000, '\n');
        if(isdigit(c[0]) && isalpha(c[1]))
        {
            c[1] = toupper(c[1]);
        }
        return;
    }
}

void UltimateChecker(char c, char n,char PlaneSeat[7][4])
{

    int sheet;
    int ro;
    if (c >= 65 && c <=68)
    {
        sheet = c - 'A';
    }
    else
    {
        cout <<"*** Error in input. Please make another request. ***"<< endl;
        return;
    }
    ro = n - '1';
    if (0 > ro && ro >= 7)
    {
        cout <<"*** Error in input. Please make another request. ***"<< endl;
        return;
    }
    if (PlaneSeat[ro][sheet] == 'X')
    {
        cout <<"***The seat is taken. Please make another request. *** "<< endl;
    }
    else
        PlaneSeat[ro][sheet] = 'X';
    print2(PlaneSeat);
    return;
}
int main()
{
    char c[3];
    char Y_N;
    char PlaneSeat[7][4];
    ArrayMaking(PlaneSeat);
    print(PlaneSeat);
    do
    {
        getInput(c);
        cout << endl;
        UltimateChecker(c[1],c[0],PlaneSeat);
        cout << endl;
        cout  << "More seats (y/Y)?";
        cin >> Y_N;
            cin.ignore(10000, '\n');
    }
    while (Y_N=='Y'||Y_N=='y');

    return 0;
}

/
Last edited on
Bump out of desperation.
Topic archived. No new replies allowed.