I have a doubt in dynamic memory allocation (malloc
)
Say
ivar=(int*)malloc(1*sizeof(int));
What the above code will do? Will it create address for allocations?
Also which is the standard way to get values in malloc? (Say i as loop variable)
scanf("%d",&ivar[i]);
OR
scanf("%d",ivar+i);
int main()
{
int *ivar;
ivar=(int*)malloc(1*sizeof(int));
printf("%u",ivar); // outputs 2510
printf("%u",&ivar);// outputs 65524
} // please explain why it is…
Thanks in advance.