I’m puzzled as to how the header, return and call would look.
This is what gave me the error “Wrong pointer type”
int **CreatesArray (int r,int c)
{
int table [r][c];
printf ("Enter clause orientations.\n");
for (int i = 0; i<r;i++)
{
for (int j = 0;j<c;j++)
{
scanf ("%d",&table[i][j]);
}
}
return table;
}
Function call from main:
int **tableaux;
tableaux = CreatesArray(ROWS,COLS);
Why is this not the correct way of doing it?
NOTE: Will post TableCreator shortly
Your function is a little off. For one thing, you’re creating the two-dimensional array
table[r][c]on the stack, and you can’t return stack-allocated arrays from functions in C.You will have to allocate the table on the heap, and return that. Here’s an example:
If you don’t know about C memory allocation and management, read some stuff here: