🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3944

Re: Placement of string literals

#3944
From: Zefram
Date: Thu, 07 Sep 1995 09:47
22 lines
1160 bytes
John Winters <john@polo.demon.co.uk> wrote:
>Or indeed, as :
>
>const char __foo[] = {'H','e','l','l','o',' ','w','o','r','l','d','\0'};
>char *foo;
>const char *bar;
>foo = (char *) __foo;
>bar = (const char *) __foo;

Indeed.  That's the effect of the const.

Actually, considering that string literals semantically have the type
char *, even though they behave like const char *, it would be more
accurate to write the above as

const char __foo[] = {'H','e','l','l','o',' ','w','o','r','l','d','\0'};
char *foo;
const char *bar;
foo = (char *) __foo;
bar = (char *) __foo;

-zefram
Technical Details
Message-ID: <1995Sep7.094751.4404@dcs.warwick.ac.uk>
Path: arc1-ca.pugleaf.net!news.dcs.warwick.ac.uk!not-for-mail
References: <42c4uu$9e5@sparcserver.lrz-muenchen.de> <1995Sep4.123536.3152@dcs.warwick.ac.uk> <DEG3zz.66q@polo.demon.co.uk>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!news.dcs.warwick.ac.uk!not-for-mail
From: A.Main@dcs.warwick.ac.uk (Zefram)
Subject: Re: Placement of string literals
X-Nntp-Posting-Host: stone
Message-ID: <1995Sep7.094751.4404@dcs.warwick.ac.uk>
Keywords: string literals, const
Sender: news@dcs.warwick.ac.uk (Network News)
Organization: Department of Computer Science, Warwick University, England
References: <42c4uu$9e5@sparcserver.lrz-muenchen.de> <1995Sep4.123536.3152@dcs.warwick.ac.uk> <DEG3zz.66q@polo.demon.co.uk>
Date: Thu, 7 Sep 1995 09:47:51 GMT