thank you sir, very well explained .
On Sat, Dec 22, 2012 at 12:47 PM, saurabh singh wrote:
> **p; *
> Explanation: By default C thinks everything is an int. So p is a global
> variable of type *pointer to an int.*Now like other global variables it
> is very very very very likely that the compi
**p; *
Explanation: By default C thinks everything is an int. So p is a global
variable of type *pointer to an int.*Now like other global variables it is
very very very very likely that the compiler will associate p with an
address that is *0.*Or in terms of pointers it is *NULL.* That is
printf(
I am afraid both of you are incorrect..
1. since the code modified by you will compile but give sigsegv anyway.
2. The statement " *p = 0; " has nothing to do with the " random address"
you are talking about.
On Mon, Dec 17, 2012 at 7:25 PM, Prakhar Jain wrote:
> You are initialising random memo
compiler fails to know the type of memory to be pointed to (int,
char...etc.) by p... thus leading to a runtime error !
the modified code compiles :
int *p;main(){*p=0;}
On Mon, Dec 17, 2012 at 8:51 PM, Saurabh Paliwal <
saurabh.paliwa...@gmail.com> wrote:
> because p is a dangling pointer and
You are initialising random memory address with 0, which OS doesn't allow.
On 12/17/12, Shubham Sandeep wrote:
> how does this code achieve SIGSEGV
> code:
> *p;main(){*p=0;}
>
> --
> Regards,
> SHUBHAM SANDEEP
> IT 3rd yr.
> NIT ALD.
>
> --
>
>
>
--
--
Prakhar Jain
IIIT Allahabad
B.Tech
because p is a dangling pointer and that you can't modify what it's
pointing to.
On Mon, Dec 17, 2012 at 7:10 PM, Shubham Sandeep wrote:
> how does this code achieve SIGSEGV
> code:
> *p;main(){*p=0;}
>
> --
> Regards,
> SHUBHAM SANDEEP
> IT 3rd yr.
> NIT ALD.
>
> --
>
>
>
--
-Sau
how does this code achieve SIGSEGV
code:
*p;main(){*p=0;}
--
Regards,
SHUBHAM SANDEEP
IT 3rd yr.
NIT ALD.
--