Monday, May 24, 2010

How to make a multi-dimensional array in C++?

Can anyone help me make a multi-dimesional array, im totally lost in one of my class. can anyone make me an small example program like translating a numeric entry to a text entry AND translate a text entry to a numeric one.

How to make a multi-dimensional array in C++?
let assume that your cp keypad is laid out like this.





just declare a variable like this.





char text[3][3][4];





then populate that like this..





text[0][0][0]='a';


text[0][0][1]='b';


text[0][0][2]='c';





text[0][1][0]='d';


text[0][1][1]='e';


text[0][1][2]='f';





text[0][2][0]='g';


text[0][2][1]='h';


text[0][2][2]='i';





and so on..


just visualize the 3d array as a table which is cell has 3 arrays on it...





i can help you more if you want to.. ^_^v


No comments:

Post a Comment