   2D Char array help!
  How this work:void main(){char twoD[2][3] = {{'a', 'b', 'c'}, {'d', 'e', 'f'}};cout << twoD[1][1] << endl;system("pause");}And this doesn't?!?!?void main(){int numRows = 2;int numCols = 3;char twoD[numRows][numCols] = {{'a', 'b', 'c'}, {'d', 'e', 'f'}};cout << twoD[1][1] << endl;system("pause");}AND once I fix this how can I return a 2d Char array???char[][] charReturn(char twoD[][]){char twoD[2][3] = {{'a', 'b', 'c'}, {'d', 'e', 'f'}};return twoD;}void main(){char twoD[2][3];twoD = charReturn(twoD);cout << twoD[1][1] << endl;system("pause");}I would like to avoid pointers! :(   
  The first problem pertains to the indexing of the array. They numbers that you use must be constant meaning they cannot change during runtime. numRows and numCols are variables that are not constant therefore they cannot be used to index the array. You must either make the const, use #define, or put in an integer literal.The second problem, I recommended checking out a tutorial on the relation of pointers and arrays. You say you want to avoid pointers... I'm not sure if that can be done D:   ;Quote:Original post by boogyman19946use #definePlease no.There are two advantages of using const instead of define:The type of the constant is defined, this means the compiler can do type checking.Secondly, they are variables with a  definite scope.As for the OP why would you want to avoid pointers? You will need to learn how to use them at some point. Plus with the latest features of the standard library you can use a shared_ptr<type> which will handle the new, delete and null of the pointer for you, however it is crucial you understand the concept behind a pointer before you rely on shared_ptr too much.   ;  Can't you just saystd::vector<std::string> v;v.push_back("abc");v.push_back("def");and be done with it? It's hard to tell what you are trying to achieve from your variable names though.   