I’m trying to create a continuous block of memory in one function call that has the first part of the memory as pointer arrays to the other blocks. The function works with an index notation though I’d like to use compact pointer
Type **TwoD(size_t rows, size_t cols)
{
Type **p1, **prows, *pcol;
p1 = (Type **)malloc(rows * sizeof(Type *) + rows * cols * sizeof(Type));
// ??? something wrong here ??? I'd rather use this style if possible
//
//index notation works
return prows;
}
The value of prows returned is different.
prows is changed in this case:
while the other case, no change of prows (which is still p1):
So, what you can do is at the end return p1 instead of prows.