Lesson 6

Pointers to pointers

// Creating two dimensional array of size H×W
int **ary = new int*[H];
for(int i = 0; i < H; ++i) {
    ary[i] = new int[W];

// todo: some operations on the array

// Free memory
for(int i = 0; i < H; ++i) {
    delete[] ary[i];
delete[] ary; 
Task 0

Create an two dimensional array of the size given by an user. Value of each cell should be calculated as: column index + row index.

Task 1

Create a method, which displays an array.

Task 2

Write a method, that swaps two rows without direct modification of cell values.

Task 3

Write a method, which will create x dimensional array, where 1<x<2. It means: if you modify a value of one column, it will affect also values in another column.

Task 4

Write a method, which will fulfill a n-elements array from a given range without repetition.

Task 5

Write a method, which will take const char* as an argument and will return array of words stored in the given text.