Re: correct way to initialize pointer...

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

 



Mandeep Sandhu 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;

"[#3] An integer constant expression with  the  value  0,  or
such  an  expression  cast  to type void *, is called a null
pointer   constant."

You could do char *p = 1 - 1; char *q = 0; char *r = 1 / 2;
if you wish.

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