Can someone please explain a few things?
I have added in comments on the parts that I don't quite understand. Please any links and/or information you find relevant to my questions. Don't point me to a link on pointers, I know what they are, just don't understand some situations they are used in. I would love to have these two questions answered, they really bother me.
Code:
#include<stdio.h>
int main()
{
int *ptr_one;
ptr_one = (int *)malloc(sizeof(int)); //Why has this been type-casted?
if (ptr_one == 0)
{
printf("ERROR: Out of memory\n");
return 1;
}
*ptr_one = 25; //Why do these have to have the asterisk in-front?
printf("%d\n", *ptr_one);
free(ptr_one);
getchar();
return 0;
}