Mar 1, 2004 #1 xlav Technical User Joined Oct 23, 2003 Messages 223 Location JM Trying to declare and initialize a 3 dimensional array but can't get it right. Any help appreciated. -X
Trying to declare and initialize a 3 dimensional array but can't get it right. Any help appreciated. -X
Mar 1, 2004 #2 Bones3 Programmer Joined Jul 27, 2003 Messages 151 Location US In C++ declare 3D arrays like this: int 3D[width][length][height]; i.e. int 3D[5][5][5]; Then obviously you would access the data like so: int 3D[5][1][3] = 10; -Bones Upvote 0 Downvote
In C++ declare 3D arrays like this: int 3D[width][length][height]; i.e. int 3D[5][5][5]; Then obviously you would access the data like so: int 3D[5][1][3] = 10; -Bones
Mar 1, 2004 1 #3 obislavu Programmer Joined May 31, 2003 Messages 974 Location CA Code: int a[3][4][2]= { {{0,0},{0,0},{0,0},{0,0}} ,{{0,0},{0,0},{0,0},{0,0}} ,{{0,0},{0,0},{0,0},{0,0}} }; -obislavu Upvote 0 Downvote
Code: int a[3][4][2]= { {{0,0},{0,0},{0,0},{0,0}} ,{{0,0},{0,0},{0,0},{0,0}} ,{{0,0},{0,0},{0,0},{0,0}} }; -obislavu
Mar 1, 2004 Thread starter #4 xlav Technical User Joined Oct 23, 2003 Messages 223 Location JM Thanks for your reply. Example given by obislavu is very helpful. -X Upvote 0 Downvote
Mar 2, 2004 #5 Leibnitz Programmer Joined Apr 6, 2001 Messages 393 Location CA you could also do it like this: Code: int a[2][5][6] = {0}; Upvote 0 Downvote