Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #85673

Re: Is a char array initializer a "string literal"?

Path csiph.com!news.mixmin.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.c++
Subject Re: Is a char array initializer a "string literal"?
Date Tue, 26 Jul 2022 19:24:31 -0700
Organization None to speak of
Lines 24
Message-ID <87k07zxpgg.fsf@nosuchdomain.example.com> (permalink)
References <tbo6pa$cdd$1@gioia.aioe.org> <tbq2gk$2a4ok$1@dont-email.me>
MIME-Version 1.0
Content-Type text/plain
Injection-Info reader01.eternal-september.org; posting-host="4cade4b69894ce75454f6fba9132da96"; logging-data="2552379"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191Q71RBdKlBkmUfVQCxUDh"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock sha1:hu7WNOCR2hC/CvCRJ1+EmvSNodw= sha1:Oawb0wBzl6tSUxYtf0PoadKpj6g=
Xref csiph.com comp.lang.c++:85673

Show key headers only | View raw


Andrey Tarasevich <andreytarasevich@hotmail.com> writes:
> On 7/26/2022 12:57 AM, Juha Nieminen wrote:
>> In another forum I was discussing string literals and char arrays.
>> During the conversation this question occurred to me:
>> In an array initialization like this:
>>      char str[] = "hello";
>> can that "hello" even be considered a "string literal", or should it
>> be classified as something else?
>
> Yes, it is a string literal. I.e. formally it is an independent object
> with static storage duration, independent and separate from `str` in 
> your example.

It is a string literal, i.e., it is a source code token starting and
ending with a '"' character.  The corresponding object with static
storage duration is not a string literal.  It doesn't exist until
execution time.

[...]

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Back to comp.lang.c++ | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Is a char array initializer a "string literal"? Juha Nieminen <nospam@thanks.invalid> - 2022-07-26 07:57 +0000
  Re: Is a char array initializer a "string literal"? Muttley@dastardlyhq.com - 2022-07-26 08:03 +0000
  Re: Is a char array initializer a "string literal"? Öö Tiib <ootiib@hot.ee> - 2022-07-26 01:51 -0700
    Re: Is a char array initializer a "string literal"? Juha Nieminen <nospam@thanks.invalid> - 2022-07-26 10:07 +0000
      Re: Is a char array initializer a "string literal"? Öö Tiib <ootiib@hot.ee> - 2022-07-26 05:10 -0700
        Re: Is a char array initializer a "string literal"? Öö Tiib <ootiib@hot.ee> - 2022-07-26 06:18 -0700
        Re: Is a char array initializer a "string literal"? Juha Nieminen <nospam@thanks.invalid> - 2022-07-26 16:03 +0000
          Re: Is a char array initializer a "string literal"? "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-07-26 18:18 +0200
            Re: Is a char array initializer a "string literal"? Juha Nieminen <nospam@thanks.invalid> - 2022-07-27 07:40 +0000
              Re: Is a char array initializer a "string literal"? Öö Tiib <ootiib@hot.ee> - 2022-07-27 01:17 -0700
  Re: Is a char array initializer a "string literal"? Bo Persson <bo@bo-persson.se> - 2022-07-26 11:11 +0200
  Re: Is a char array initializer a "string literal"? Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-07-26 02:30 -0700
    Re: Is a char array initializer a "string literal"? Juha Nieminen <nospam@thanks.invalid> - 2022-07-26 10:19 +0000
    Re: Is a char array initializer a "string literal"? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-07-26 12:03 -0700
      Re: Is a char array initializer a "string literal"? Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-07-27 01:56 -0700
        Re: Is a char array initializer a "string literal"? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-07-27 11:02 -0700
  Re: Is a char array initializer a "string literal"? "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-07-26 11:36 +0200
    Re: Is a char array initializer a "string literal"? Juha Nieminen <nospam@thanks.invalid> - 2022-07-26 10:22 +0000
      Re: Is a char array initializer a "string literal"? "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-07-26 16:50 +0200
  Re: Is a char array initializer a "string literal"? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-07-26 12:13 -0700
  Re: Is a char array initializer a "string literal"? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-07-26 17:56 -0700
    Re: Is a char array initializer a "string literal"? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-07-26 19:24 -0700
      Re: Is a char array initializer a "string literal"? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-07-27 13:05 -0700
        Re: Is a char array initializer a "string literal"? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-07-27 15:38 -0700

csiph-web