CS 202
#include <iostream> #include <fstream> using namespace std; const int SIZE = 3; int main() { int *** array3D; ifstream in; in.open("input.txt"); array3D = new int**[SIZE]; /********************************* Code to allocate 3D array goes here ********************************** ********************************** Read from file and enter values into array ***********************************/ in.close(); cout << "Reference to array3D[2][1][0]" << endl; /*********************************************** Pointer Arithmetic for the above indices ***********************************************/ cout << ***array3D << endl; /********************************************* Reset the array3D pointer **********************************************/ cout << array3D[2][1][0] << endl; cout << "Reference to array3D[2][2][1]" << endl; /*********************************************** Pointer Arithmetic for the above indices ***********************************************/ cout << ***array3D << endl; /********************************************* Reset the array3D pointer **********************************************/ cout << array3D[2][2][1] << endl; cout << "Reference to array3D[2][1][2]" << endl; /*********************************************** Pointer Arithmetic for the above indices ***********************************************/ cout << ***array3D << endl; /********************************************* Reset the array3D pointer **********************************************/ cout << array3D[2][1][2] << endl; cout << "Reference to array3D[2][2][2]" << endl; /*********************************************** Pointer Arithmetic for the above indices ***********************************************/ cout << ***array3D << endl; /********************************************* Reset the array3D pointer **********************************************/ cout << array3D[2][2][2] << endl; cout << "Reference to array3D[0][1][2]" << endl; /*********************************************** Pointer Arithmetic for the above indices ***********************************************/ cout << ***array3D << endl; /********************************************* Reset the array3D pointer **********************************************/ cout << array3D[0][1][2] << endl; /******************************************** Deallocate 3D array ********************************************/ return 0; }
Can you please help me , I am completely lost.
Well, what problem are you having?
I mean, if you are in CS 202, how can you be completely lost? That class number sounds like you should have had something before this one, so you should have some idea about the code. Thus, I wonder which part it is that has you baffled.
I've had basic C++ but this is a brand new topic.
OK, so what is the new part? What is it that you are having trouble with?
Join our real-time social learning platform and learn together with your friends!