Behold the following code:
#include<stdio.h>
void function ();
int main()
{
int * a;
*a=9;//this is supposed to give error as I am trying to
// dereference an unallocated pointer
// but it does not
printf("%d",*a);
function();
}
void function()
{
int * a;
*a=9;//this gives an error as I am trying to
// dereference an unallocated pointer
printf("%d",*a);
return;
}
Output is 9 and then the program crashes... Why? The difference for main() and function() For main() we declare a pointer type then without the use of calloc or malloc is it by default allocated memory?