#include <stdio.h>

void change_values(int **p, int rows, int cols) {
    int i, j;
    int *ptr;
    for (i = 0; i < rows; i++) {
        for (j = 0; j < cols; j++) {
            ptr = *(p + i) + j;
            *ptr = i * j;
            (*ptr)++;
        }
    }
}

int main() {
    int rows = 3, cols = 4;
    int i, j;
    int **p = (int **)malloc(rows * sizeof(int *)); // allocate memory for rows

    // allocate memory for columns
    for (i = 0; i < rows; i++) {
        p[i] = (int *)malloc(cols * sizeof(int));
    }

    // initialize array
    change_values(p, rows, cols);

    // print array
    for (i = 0; i < rows; i++) {
        for (j = 0; j < cols; j++) {
            printf("%d ", p[i][j]);
        }
        printf("\n");
    }

    // free memory
    for (i = 0; i < rows; i++) {
        free(p[i]);
    }
    free(p);

    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: