Member • Jan 20, 2009
Initializing a 2-D character array
The code was:
char acUsername[3][2]={"john",john1","smith","smith2","dennis","dennis3"};
Any idea where I went wrong?
Member • Jan 20, 2009
Member • Jan 20, 2009
Member • Jan 21, 2009
char acUsername[3][2]={"john",john1","smith","smith2","dennis","dennis3 "};I think this is a 3D array and not a 2D array. If a char array is of dimension [3][2], then it canhold a total of 6 characters only. For your array, you have to initialize it as [3][2][6]. That should solve the problem. Or if you want to work with pointers, what MaRo said is also absolutely correct. You can initialize it as a char pointer pointing to a char array.
Member • Jan 22, 2009
Member • Feb 3, 2009