"sushant" <> wrote:
> according to the definition of declaration of a variable "the variable
> is not allocated any space in the memory till it is defined".
>
> so the code:
>
> int main(void)
> {
> int x,*p;
Yech - Google-unindented code!
> p=&x;
> printf("%p",p);
> return 0;
> }
>
> should generate an error bcos x is only declared not defined...
Wrong. That's not just a declaration of x (and p), it's a definition as
well. If you want to declare, but not define, a variable, declare it
using extern.
(BTW, for fully conforming code, you should cast that pointer to void *
before printf()ing it using "%p".)
Richard
|