Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

re PCSZ

1 view
Skip to first unread message

Adrian Suri

unread,
Mar 12, 2007, 4:28:18 PM3/12/07
to
Hi

can anyone explain the difference between the data type of PSZ and
PCSZ, from my understanding PSZ is a pointer to an array of char, and is
a pointer to a const PCSZ (without having to specify const), but is
there any more to this?

Regards

Adrian Suri

Lars Erdmann

unread,
Mar 12, 2007, 5:48:26 PM3/12/07
to
Adrian Suri schrieb:
PCSZ is a constant pointer to a zero terminated string while PSZ is a
pointer to a zero terminated string.
For a C compiler, PSZ and PCSZ don't have any noticable difference (at
least, from what I see) but for a C++ compiler, it allows for more
strict type checking. If you pass a non-const pointer where PCSZ is
expected, a C++ compiler will report an error. If you want to
circumvent, you will need to explicitely cast the pointer to a PCSZ.
Remember that you can force use of C++ compiler normally by giving your
source files an extension of .cpp or by setting the corresponding
compiler switch.

Lars

Paul Ratcliffe

unread,
Mar 12, 2007, 9:11:12 PM3/12/07
to
On Mon, 12 Mar 2007 22:48:26 +0100, Lars Erdmann <lars.e...@arcor.de>
wrote:

> PCSZ is a constant pointer to a zero terminated string while PSZ is a
> pointer to a zero terminated string.

I thought it was a pointer to a constant zero terminated string, which is
not the same thing i.e. you can change the pointer, but not the contents
of what it is pointing to.

Adrian Suri

unread,
Mar 13, 2007, 1:18:13 AM3/13/07
to
Hi

Thanks for that, thought that might be the case but was not 100% certain

Regards

Adrian

Lars Erdmann

unread,
Mar 14, 2007, 5:25:05 PM3/14/07
to
Paul Ratcliffe schrieb:
You are right, you may not assign any new content to what the pointer
points to:

PCSZ p;

p = (PCSZ)malloc(100);

*p = 'A'; /* is forbidden */
p[5] = 'A'; /* is forbidden */
*(p+10) = 'A' /* is forbidden */

Lars

0 new messages