I got some problem, i need to fill a 2D integer tab, so i made this function :
int **ft_fill_tab(void) {
int **res;
int row;
int col;
// creating a 15 cols by 10 rows TAB
res = (int **)malloc(sizeof(int *) * 10);
res[0] = (int *)malloc(sizeof(int) * 2);
res[0][1] = 15;
res[0][2] = 10;
row = 1;
col = 0;
while (row < res[0][1])
{
res[row] = (int*)malloc(sizeof(int) * res[0][1]);
while (col <= res[0][0])
{
res[row][col] = 0;
col++;
}
row++;
col = 1;
}
return (res);
}
... which i use/call from my main.c like this :
int main (void) {
// ...
int **tab_test;
tab_test = ft_fill_tab();
// ...
return (0);
}
And when i tried to compile my program, gcc said to me : warning: assignment makes pointer from integer without a cast (main.c, on ft_fill_tab(); call row)
I also tried to cast the return value of my function as any ways as possible (even in main file), but i failed to understand from where this error came up.
... Any idea? Thanks from the future !