
Originally Posted by
NoHero
The only problem: C++ might understand references, but C does not. The OP stated to use C so your solution won't help him at all.
Oh, I thought he was just another lazy C++ programmer (and dropped the obvious ++)
Well, then I'd go for evilsaltines solution:
Code:
void alloc_data(float*** data) // pass pointer (to the double pointer)
{
int i, nx, ny;
nx = 3;
ny = 3;
*data = (float **) calloc(nx, sizeof(float *));
for (i=0; i<nx; i++)
(*data)[i] = (float *) calloc(ny, sizeof(float));
}
int main(int argc, char *argv[])
{
float **data = 0;
alloc_data(&data);
}
- petter