Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int y = 4, x = 5;
- int** ptr = new int*[y];
- int* tmpPtr = new int[y*x] {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
- for (int i=0; i < y; i++)
- {
- ptr[i]=tmpPtr + (x * i);
- }
- for (int i=0; i < y; i++)
- {
- for (int j=0; j< x; j++)
- {
- cout << ptr[i][j] << " ";
- }
- cout << endl;
- }
- delete[] tmpPtr;
- delete[] ptr;
- }
Advertisement
Add Comment
Please, Sign In to add comment