Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

How many chunks could checkchunk check if checkchunk could check chunks? -- Alan Cox


devel / comp.lang.c++ / Re: char array initialized by string literal

SubjectAuthor
* char array initialized by string literalwij
+- Re: char array initialized by string literalMalcolm McLean
`* Re: char array initialized by string literalTony Oliver
 `* Re: char array initialized by string literalAlf P. Steinbach
  `- Re: char array initialized by string literalTony Oliver

1
char array initialized by string literal

<18c3734e-0acf-42eb-89d7-0b9ba8d0bed3n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=967&group=comp.lang.c%2B%2B#967

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:622a:24f:b0:406:804b:d67f with SMTP id c15-20020a05622a024f00b00406804bd67fmr233qtx.5.1690465909057;
Thu, 27 Jul 2023 06:51:49 -0700 (PDT)
X-Received: by 2002:a05:6870:3a06:b0:1bb:b65c:c28 with SMTP id
du6-20020a0568703a0600b001bbb65c0c28mr3795536oab.0.1690465908369; Thu, 27 Jul
2023 06:51:48 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Thu, 27 Jul 2023 06:51:47 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=124.218.76.41; posting-account=0Ek0TQoAAAAS0oceh95IuNV59QuIWNeN
NNTP-Posting-Host: 124.218.76.41
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <18c3734e-0acf-42eb-89d7-0b9ba8d0bed3n@googlegroups.com>
Subject: char array initialized by string literal
From: wyniijj5@gmail.com (wij)
Injection-Date: Thu, 27 Jul 2023 13:51:49 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1212
 by: wij - Thu, 27 Jul 2023 13:51 UTC

I found char array can be initialized by string literal ! Is such coding correct?

--------------------------------------
int main() {
char tnam[]="tmpnamXXXXXX";

int fd=::mkstemp(tnam);
return 0;
}

g++ t.cpp -std=gnu++11

Re: char array initialized by string literal

<d1ac1ba3-5977-4d91-a61c-9f256c505047n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=968&group=comp.lang.c%2B%2B#968

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:6214:14e6:b0:634:81f6:569b with SMTP id k6-20020a05621414e600b0063481f6569bmr352qvw.10.1690466499454;
Thu, 27 Jul 2023 07:01:39 -0700 (PDT)
X-Received: by 2002:a05:6808:15a5:b0:3a3:7087:bbfb with SMTP id
t37-20020a05680815a500b003a37087bbfbmr6203773oiw.6.1690466499262; Thu, 27 Jul
2023 07:01:39 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Thu, 27 Jul 2023 07:01:38 -0700 (PDT)
In-Reply-To: <18c3734e-0acf-42eb-89d7-0b9ba8d0bed3n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=81.143.231.9; posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 81.143.231.9
References: <18c3734e-0acf-42eb-89d7-0b9ba8d0bed3n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d1ac1ba3-5977-4d91-a61c-9f256c505047n@googlegroups.com>
Subject: Re: char array initialized by string literal
From: malcolm.arthur.mclean@gmail.com (Malcolm McLean)
Injection-Date: Thu, 27 Jul 2023 14:01:39 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1597
 by: Malcolm McLean - Thu, 27 Jul 2023 14:01 UTC

On Thursday, 27 July 2023 at 14:51:57 UTC+1, wij wrote:
> I found char array can be initialized by string literal ! Is such coding correct?
>
> --------------------------------------
> int main() {
> char tnam[]="tmpnamXXXXXX";
>
> int fd=::mkstemp(tnam);
> return 0;
> }
>
> g++ t.cpp -std=gnu++11
>
Yes, that's fine.
char modifable[] = "This string can be modiifed";
const char *constant = "This string shouldn't be modified";

Re: char array initialized by string literal

<81d813fc-2a11-46e7-b50f-b2039b8ddb7en@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=969&group=comp.lang.c%2B%2B#969

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:622a:13c8:b0:403:b888:fa29 with SMTP id p8-20020a05622a13c800b00403b888fa29mr966qtk.0.1690467241065;
Thu, 27 Jul 2023 07:14:01 -0700 (PDT)
X-Received: by 2002:a9d:73c1:0:b0:6b9:982d:2397 with SMTP id
m1-20020a9d73c1000000b006b9982d2397mr7814437otk.5.1690467240773; Thu, 27 Jul
2023 07:14:00 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Thu, 27 Jul 2023 07:14:00 -0700 (PDT)
In-Reply-To: <18c3734e-0acf-42eb-89d7-0b9ba8d0bed3n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=62.249.217.89; posting-account=FHqkeAoAAACbOpBCHa7K6JTmToKlWNDp
NNTP-Posting-Host: 62.249.217.89
References: <18c3734e-0acf-42eb-89d7-0b9ba8d0bed3n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <81d813fc-2a11-46e7-b50f-b2039b8ddb7en@googlegroups.com>
Subject: Re: char array initialized by string literal
From: guinness.tony@gmail.com (Tony Oliver)
Injection-Date: Thu, 27 Jul 2023 14:14:01 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1809
 by: Tony Oliver - Thu, 27 Jul 2023 14:14 UTC

On Thursday, 27 July 2023 at 14:51:57 UTC+1, wij wrote:
> I found char array can be initialized by string literal ! Is such coding correct?
>
> --------------------------------------
> int main() {
> char tnam[]="tmpnamXXXXXX";
>
> int fd=::mkstemp(tnam);
> return 0;
> }
>
> g++ t.cpp -std=gnu++11

N3096: 6.7.10 Initialization

15 - An array of character type may be initialized by a character string
literalor UTF-8 string literal, optionally enclosed in braces.
Successive bytes of the string literal (including the terminating null
character if there is room or if the array is of unknown size) initialize
the elements of the array.

Re: char array initialized by string literal

<u9u9v8$1ucne$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=970&group=comp.lang.c%2B%2B#970

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: alf.p.steinbach@gmail.com (Alf P. Steinbach)
Newsgroups: comp.lang.c++
Subject: Re: char array initialized by string literal
Date: Thu, 27 Jul 2023 19:36:39 +0200
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <u9u9v8$1ucne$1@dont-email.me>
References: <18c3734e-0acf-42eb-89d7-0b9ba8d0bed3n@googlegroups.com>
<81d813fc-2a11-46e7-b50f-b2039b8ddb7en@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Jul 2023 17:36:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1ee78832fdad33a56dfadeddfc550198";
logging-data="2044654"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hXsIVC7/y1sVKhBdca5tf"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:8exwc4mInz89pfm9DE0FMZiWkqo=
In-Reply-To: <81d813fc-2a11-46e7-b50f-b2039b8ddb7en@googlegroups.com>
Content-Language: en-US
 by: Alf P. Steinbach - Thu, 27 Jul 2023 17:36 UTC

On 2023-07-27 4:14 PM, Tony Oliver wrote:
> On Thursday, 27 July 2023 at 14:51:57 UTC+1, wij wrote:
>> I found char array can be initialized by string literal ! Is such coding correct?
>>
>> --------------------------------------
>> int main() {
>> char tnam[]="tmpnamXXXXXX";
>>
>> int fd=::mkstemp(tnam);
>> return 0;
>> }
>>
>> g++ t.cpp -std=gnu++11
>
> N3096: 6.7.10 Initialization
>
> 15 - An array of character type may be initialized by a character string
> literalor UTF-8 string literal, optionally enclosed in braces.
> Successive bytes of the string literal (including the terminating null
> character if there is room or if the array is of unknown size) initialize
> the elements of the array.

That appears to be the C standard, while this is a C++ group.

The languages are not the same.

C++ requires that there is room for a terminating zero.

- Alf

Re: char array initialized by string literal

<edc6661e-318e-4212-be45-02c28f0a93b5n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=971&group=comp.lang.c%2B%2B#971

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:6214:a4b:b0:635:e010:970e with SMTP id ee11-20020a0562140a4b00b00635e010970emr6662qvb.13.1690543157857;
Fri, 28 Jul 2023 04:19:17 -0700 (PDT)
X-Received: by 2002:a05:6808:1818:b0:39c:cd8e:998f with SMTP id
bh24-20020a056808181800b0039ccd8e998fmr4134432oib.0.1690543157581; Fri, 28
Jul 2023 04:19:17 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Fri, 28 Jul 2023 04:19:17 -0700 (PDT)
In-Reply-To: <u9u9v8$1ucne$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=62.249.217.89; posting-account=FHqkeAoAAACbOpBCHa7K6JTmToKlWNDp
NNTP-Posting-Host: 62.249.217.89
References: <18c3734e-0acf-42eb-89d7-0b9ba8d0bed3n@googlegroups.com>
<81d813fc-2a11-46e7-b50f-b2039b8ddb7en@googlegroups.com> <u9u9v8$1ucne$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <edc6661e-318e-4212-be45-02c28f0a93b5n@googlegroups.com>
Subject: Re: char array initialized by string literal
From: guinness.tony@gmail.com (Tony Oliver)
Injection-Date: Fri, 28 Jul 2023 11:19:17 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2408
 by: Tony Oliver - Fri, 28 Jul 2023 11:19 UTC

On Thursday, 27 July 2023 at 18:36:58 UTC+1, Alf P. Steinbach wrote:
> On 2023-07-27 4:14 PM, Tony Oliver wrote:
> > On Thursday, 27 July 2023 at 14:51:57 UTC+1, wij wrote:
> >> I found char array can be initialized by string literal ! Is such coding correct?
> >>
> >> --------------------------------------
> >> int main() {
> >> char tnam[]="tmpnamXXXXXX";
> >>
> >> int fd=::mkstemp(tnam);
> >> return 0;
> >> }
> >>
> >> g++ t.cpp -std=gnu++11
> >
> > N3096: 6.7.10 Initialization
> >
> > 15 - An array of character type may be initialized by a character string
> > literalor UTF-8 string literal, optionally enclosed in braces.
> > Successive bytes of the string literal (including the terminating null
> > character if there is room or if the array is of unknown size) initialize
> > the elements of the array.
>
> That appears to be the C standard, while this is a C++ group.
>
> The languages are not the same.
>
> C++ requires that there is room for a terminating zero.
>
>
> - Alf

Yes - I realised this wasn't in clc as soon as I posted it.
My immediate retraction request was, of course, ignored.
Apologies for any confusion caused.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor