Re: correct way to initialize pointer...

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

 



On 10/23/06, Mandeep Sandhu <mandeepsandhu.chd@xxxxxxxxx> wrote:
Hi All,

This is more of a 'C' question than a kernel one. But since i'll be putting
this
in a module, I thought I'd ask here too...

Whats the correct way to initialize a pointer?

1. char *p = 0;
 OR
2. char *p = NULL;
Both are right. I believe that NULL is defined as (void *) 0 or 0,
depending on the language (C or C++), so that it can be assigned to
any pointer without generating warnings.
Check man stddefs.h and the file itself.

Om.

--
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