PDA

View Full Version : Multidimensional arrays of strings/C++


jakbo
02-05-2006, 02:32 AM
I'm having trouble with this bit of code:

const int seatSize=2;
const int rows=15;
const int columns=30;

int main(){
char myArray[15][30][2]={{{"#"},{"#"},{"#"},{"#"},{"#"}}}; //and so on so that I have 15 rows of 30 seats. Am I doing something wrong with this initialization?

return 0;
}

oracleguy
02-05-2006, 03:23 AM
Well... what is the problem you are having with it? At first glance I don't see anything majorly wrong with it, so whats the error message you are getting?

jakbo
02-08-2006, 08:52 AM
Thanks for the reply. I can operate on it easier this way, anyway. I ended up doing it a different way:


const int seats = 31;
const int rows = 15;

int main(){

char myArray[rows][seats] = {"##############################",
"##############################",
"##############################",
"##############################",
"##############################",
"##############################",
"##############################",
"##############################",
"##############################",
"##############################",
"##############################",
"##############################",
"##############################",
"##############################",
"##############################"};

return 0;
}