this function is supposed to allocate a matrix ('resMat') of 1 rows with 2 cols.
for some reason all I get in 'resMat' is 1 row with 1 col.
any idea why? thanks.
void Ex2()
{
int** resMat = NULL;
int rows = 1;
int* cols = (int*)calloc(rows, sizeof(int*));
cols = {2};
int i;
resMat = (int**)calloc(rows, sizeof(int*));
assert(resMat);
for (i = 0; i < rows; i++)
{
resMat[i] = (int*)calloc(cols[i], sizeof(int)); // cols[i]=cols[0]=2
assert(resMat[i]);
}
I changed the code a bit to be more readable. 'rows' and 'cols' are actually defined by other functions and that's why 'cols' is an array(in case rows>1)