Hey guys, just having some trouble with a pretty simple program and I can't for the life of me understand where the problem lies. Maybe someone can give me a hand?
Code:
int ** createArray(int rows, int cols)
{
int i;
int **ptr_9 = (int **)malloc(rows * sizeof(int *));
if (ptr_9 == NULL)
{
printf("Error");
return 1;
}
for (i = 0 ; i < rows ; i++)
{
ptr_9[i] = (int *)malloc(cols * sizeof(int));
}
return ptr_9;
}
as far as I can see this should be setting aside the memory for ptr_9 which is then linked to a pointer in my main(). Now it is in fact doing this however cygwin is throwing me the "return makes pointer from integer without a cast" warning. Can someone tell me where the problem lies? I essentially have the same code operating elsewhere with no problems. Thanks in advance!