Mar 1, 2004 #1 xlav Technical User Oct 23, 2003 223 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 Jul 27, 2003 151 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 May 31, 2003 974 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 Oct 23, 2003 223 JM Thanks for your reply. Example given by obislavu is very helpful. -X Upvote 0 Downvote
Mar 2, 2004 #5 Leibnitz Programmer Apr 6, 2001 393 CA you could also do it like this: Code: int a[2][5][6] = {0}; Upvote 0 Downvote