Hello, I am new to this forum. Kindly tolerate any mistakes.
I read that Memory is allocated during definition of a variable and not during declaration. Declaration is something like,
And definition is assigning some value to it. This is what my professor taught.
My doubt is if memory is not allocated during declaration, then how the compiler successfully compiles and runs the following, which i had already tried.
Code:
#include<stdio.h>
#include<conio.h>
int main()
{
int c;
int *p=&c;
printf("%x",p);
getch();
return 0;
}
The variable c is only declared. But the program outputs a memory address. Shouldn't it show an error?
Thanks in Advance.