Re: *(int *)0=0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 22, 2004 at 22:22:01 -0800, prasanna wakhare wrote:
> Hi all,
> sorry for silly question again.
> 
> in *(int * )0=0
> 
> we are dereferencing the NULL pointer coz'

Sure we do.

> (int *)0 is pointer to NULL

It's THE NULL pointer. (NULL is not a variable, so there is no pointer
TO NULL).

> and *(int *)0 is what we called dereferencing the ptr,
> 
> but about syntax
> 
> (int *)0 --> how compiler interprets it while 
> parsing phase or in any complex pointer assignment
> can anybody explain this syntax?

Type in parenthesis (eg. (int *)) is a typecast operator. Thus 0 (which
is a constant of type int) is cast to (int *). Casting integeral type to
pointer means to intepret the integeral value as an address.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux