Re: const modifier

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

 



Joseph A Knapka wrote:
> tune more wrote:
> 
>> Hi,
>>
>> Here is an example of "const modifier" usage:
>>      int execv(const char *path, char *const argv[]);
>> Is there any different between const before char * and
>> const after char *.
>>
> 
> const char* pc1; /* A pointer to constant characters: *pc1 = 'a'
>                     will fail to compile, but pc1="a" is OK. */
> char * pc2 const; /* A constant pointer to non-const character.
>                     *pc2='a' is OK, but pc2="a" will fail
>                     to compile. */

Sorry, that second decl should be

char * const pc2; /* A const * to non-const char */

> You need to find a copy of a recent edition of K&R (that
> is, Kernighan & Ritchie, "The C Programming Language").

...and apparently I need to re-read mine...

Cheers,

-- Joe



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