Same invalid conversion error
Mar 4, 2014 at 10:33pm UTC
I'm a student and pretty new to C++. I am trying to print a seating chart for a plane but I need to start off with an empty plane. '*' designates an empty seat.
But, for whatever reason I keep getting this error
error: invalid conversion from 'char' to 'char (*)[6]' [-fpermissive
I don't get the error until I call the function in int main().
^
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
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
const int COL_SIZE = 6;
const int ROW_SIZE = 12;
void printChart(char seatChart[ROW_SIZE][COL_SIZE])
{
cout << setw(8)<< "A" << setw(8)<< "B" << setw(8)<< "C"
<< setw(16)<< "D" << setw(8)<< "E" << setw(8)<< "F" << endl;
for ( int i = 0;i < ROW_SIZE;i++){
cout << "Row " << i + 1;
for ( int j = 0; j < COL_SIZE; j++){
if (COL_SIZE == 3)
cout << setw(16) << seatChart[i][j];
else
cout << setw(8) << seatChart[i][j];
}
cout << endl;
}
}
int main()
{
char seatChart[ROW_SIZE][COL_SIZE];
for ( int i = 0;i < ROW_SIZE;i++){
for ( int j = 0; j < COL_SIZE; j++){
seatChart[i][j]= static_cast <char >('*' );
}
}
printChart(seatChart[ROW_SIZE][COL_SIZE]);
return 0;
}
Mar 4, 2014 at 10:39pm UTC
seatChart[ROW_SIZE][COL_SIZE]
is an (out of bound) array element of type char.
seatChart
is the array so line 36 should be printChart(seatChart);
Mar 4, 2014 at 10:43pm UTC
Ok...I get it. That worked. Thank you.
Topic archived. No new replies allowed.