Article View: comp.std.c
Article #9Re: Questions about conversions of pointer-to-qualified types.
From: Lawrence H. Miller
Date: Tue, 27 Oct 1992 19:45
Date: Tue, 27 Oct 1992 19:45
32 lines
1426 bytes
1426 bytes
In article <1323@tdat.teradata.COM> swf@tdat.teradata.com (Stanley Friesen) writes: > >No, it is not legal. This is identical in `meaning' to: > void *vp; > const char *ccp; > vp = ccp; >[The order of "const" and "char" does not matter]. Nope. const char *ccp; means that ccp is a pointer (not a const pointer) to a constant char. After this declaration, an assignment to p is valid; an assignment to *p is not. char * const ccp; means that ccp is a constant pointer to a char. The declaration is vacuous, since we cannot now assign to ccp; it must be initialized when declared. So an assignment to ccp is invalid; an assignment to *ccp is valid. Can we have a constant pointer to a constant char? Sure: const char * const ccp = "Hello world\n"; You can't assign to ccp and you can't assign to *ccp. -- Larry Miller The Aerospace Corporation lmiller@aero.org PO Box 92957 310-336-5597 LA, CA 90009-2957
Technical Details
Message-ID:
<1ck68gINNeba@news.aero.org>Path:
arc1-ca.pugleaf.net!sparky!uunet!gumby!wupost!usc!news.aero.org!lmillerReferences:
<1992Oct27.073329.6679@netcom.com> <1323@tdat.teradata.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!gumby!wupost!usc!news.aero.org!lmiller From: lmiller@aero.org (Lawrence H. Miller) Newsgroups: comp.std.c Subject: Re: Questions about conversions of pointer-to-qualified types. Date: 27 Oct 1992 19:45:20 GMT Organization: The Aerospace Corporation, El Segundo, CA Lines: 32 Message-ID: <1ck68gINNeba@news.aero.org> References: <1992Oct27.073329.6679@netcom.com> <1323@tdat.teradata.COM> NNTP-Posting-Host: palomar.aero.org