The problem is the following:
I created a dynamic matrix, using pointer to pointer
int **matrix1, **matrix2, size1 = 10, size2 = 2;
matrix1 = create_matrix(size1, size2);
//I want to copy the value of matrix1 into matrixq2 and NOT the index
**matrix2 = **matrix1
Going out on a limb about your incomplete code,
create_matrix returns an array of row pointers that point within a buffer of
ints of the appropriate size.
This means that
matrix1 points to the array of row pointers,
*matrix1 is a pointer to the array holding the actual data (address of the first element), and
**matrix1 is the value of first element.
*matrix1 are both dynamically allocated arrays.
matrix2 is an uninitialized (trash) pointer in the code you have displayed. It has neither the row pointer nor data buffers allocated.
To achieve your desired result, you need to first allocate the elements of
matrix2, then copy just the data portion of
matrix2 = create_matrix(size1, size2); memcpy(*matrix2, *matrix1, size1 * size2 * sizeof(int));
The copy operation does not touch the contents of the row pointers, just the data buffer.