I am testing example code as following, why I got warning during compile by gcc 5.6 on linux ubuntu 16-4 ?
~/c$ gcc malloc.c
malloc.c: In function ‘main’:
malloc.c:17:14: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
if(number= malloc(50*sizeof(int) )== NULL)
This is my code :
#include "stdlib.h"
#include "stdio.h"
int main()
{
char* str;
int * number;
if((str= (char *)malloc(100) )== NULL)
{
printf("malloc fail \n");
exit(1);
}
printf ("sting was allocaed \n");
if(number= malloc(50*sizeof(int) )== NULL)
{
printf("malloc fail \n");
exit(1);
}
printf ("int was allocaed \n");
return 0;
}