Invalid Conversion Error

Hey guys,

I'm in the middle of writing a program, but I came across this error that I can't seem to fix.

At line 155, the error is:
"invalid conversion from 'char (*)[3][20]' to 'char' [-fpermissive]"

Can anyone tell me what's wrong? Also, at line 186, this comes up:
array subscript has type 'char' [-Wchar-subscripts]

How can I fix this?

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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
  # include <iostream>
# include <iomanip>
# include <cctype>

using namespace std;

char get_menu_choice(char choice);

char sell_seat(char seats[][3][20]);
void print_chart(char seats[][3][20]);
/*
 void cashier(int var_2);
 void print_day_list(int var_4);
 void print_section_list(int var_5);
 */

const int MAX_DAYS = 3;
const int MAX_SECTIONS = 3;
const int MAX_SEATS = 20;

int main()
{
	char choice;
	char seats[3][3][20];

	cout << "Initializing seating chart." << endl << " " << endl;

	int d, s, n;
	for (d = 0; d < MAX_DAYS; d++) {
		for (s = 0; s < MAX_SECTIONS; s++) {
			for (n = 0; n < MAX_SEATS; n++)
				seats[d][s][n] = '-';
		}
	}

	cout << "All seats have been initialized." << endl << " " << endl;

	do {
		choice = get_menu_choice(choice);
		choice = toupper(choice);

		switch (choice) {
		case 'S':
			sell_seat(seats);
			break;

		case 'C':
			cout << "You chose C!" << endl;
			break;

		case 'D':
			cout << "You chose D!" << endl;
			break;

		case 'F':
			cout << "You chose F!" << endl;
			break;

		case 'Q':
			cout << "Quit" << endl;
			break;

		default:
			cout << "Invalid selection. Try again." << endl;
			break;
		}

		cout << " " << endl;
	} while (choice != 'Q');

	return 0;
}

char get_menu_choice(char choice)
{
	cout.fill(' ');
	cout << setw(22) << "*** Main Menu ***" << endl
			<< "S - Sell a Ticket." << endl
			<< "C - Display Seating Chart." << endl
			<< "D - Display Sales Summary - Day Listing" << endl
			<< "F - Display Sale Summary - Floor Listing" << endl
			<< "Q - Quit"<< endl
			<< "Your Choice: ";

	cin >> choice;

	return choice;
}

char sell_seat(char seats[][3][20])
{
	int d, s, n;
	char day;
	char section;
	int num;
	d = MAX_DAYS;
	s = MAX_SECTIONS;
	n = MAX_SEATS;

	//seats[d][s][n] = '-';

	cout << "Enter seat request by day (T)hursday, (F)riday, or (S)aturday"
			<< endl
			<< "followed by section (F)loor, (B)alcony, or (U)pper Balcony"
			<< endl << "followed by seat number (1 - 20)." << endl;
	cout << "Seat: ";
	cin >> day;

	day = toupper(day);
	switch (day) {
	case 'T':
		d = 0;
		break;
	case 'F':
		d = 1;
		break;
	case 'S':
		d = 2;
		break;
	default:
		cout << "Invalid choice try again";
		break;
	}

	cin >> section;
	section = toupper(section);
	switch (section) {
	case 'F':
		s = 0;
		break;
	case 'B':
		s = 1;
		break;
	case 'U':
		s = 2;
		break;
	default:
		cout << "Invalid choice try again";
		break;
	}

	cin >> num;
	if (n < 0 || n > 20)
		cout << "Invalid seat number." << endl;
	else
		n -= 1;

	if (seats[d][s][n] == '*')
		cout << "This seat has been taken." << endl;
	else {
		seats[d][s][n] = '*';
		cout << "Congratulations! You got the seat." << endl;
	}

	return seats;
}


void print_chart(char seats[][3][20])
{
	char d, s;
	int n;
	for (d = 0; d < 3; d++)
	{
		switch (d)
		{
		case 0: cout << "Thursday" << endl;
		break;
		case 1: cout << "Friday" << endl;
		break;
		case 2: cout << "Saturday" << endl;
		break;
		}
		for (s = 0; s < 3; s++)
		{
			switch (s)
			{
			case 0: cout << "Floor: " << endl;
			break;
			case 1: cout << "Balcony: " << endl;
			break;
			case 2: cout << "Upper Balcony: " << endl;
			break;
			}
			for (n = 0; n < 20; n++)
				cout << seats[d][s][n];
		}
	}
}
I figured out the error on line 155, but there's still line 186.
for the first question:the answer:
the return type of the function is char however you are returning seats which is of type char[][3][20] which are not compatible cause the second is like a triple pointer
for the second I didn't understood what is the problem -if any-
what is the whole message for error at line 155
Line 161: d and s are type char. Your compiler is warning you of unconventional usage. Everywhere else in your program, d and s are ints.
I don't see a reason why d and s should be type char.
I had already figured out line 155 (I set my program up not to return anything, since the array updates anyways).

And actually, I can't remember why I had set d and s to be char. It must have been from before I edited the code. Anyways, it's fixed now. Thanks guys.
Last edited on
Topic archived. No new replies allowed.