- #1
olikimah
- 2
- 0
"assignment makes pointer from integer without cast"
When I try to compile the program I get the error message "assignment makes pointer from integer without cast." for the line which is commented.
Could anyone help me with this?
Code:
elephant*
get_elephants()
{
elephant *current, *first;
int response;
/* create first node */
first = (elephant*)calloc(1,sizeof(elephant)); /* THIS LINE */
current = first;
printf("Elephant name? ");
scanf ("%s", current->name);
printf("Elephant weight? ");
scanf ("%d", ¤t->weight);
printf("\nAdd another? (y=1/n=0)");
scanf ("%d", &response);
while (response == 1)
{
current->next = ((elephant*)calloc(1,sizeof(elephant)) == NULL);
current = current->next;
printf("Elephant name? ");
scanf ("%s", current->name);
printf("Elephant weight? ");
scanf ("%d", ¤t->weight);
printf("\nAdd another? (y=1/n=0)");
scanf ("%d", &response);
}
current->next = NULL;
return (first);
}
When I try to compile the program I get the error message "assignment makes pointer from integer without cast." for the line which is commented.
Could anyone help me with this?
Last edited by a moderator: