Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > alt.comp.lang.c++.misc > #26
| From | Muttley@dastardlyhq.com |
|---|---|
| Newsgroups | comp.lang.c++, alt.comp.lang.c++.misc |
| Subject | Re: Counting Characters!! |
| Date | 2024-09-17 07:21 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <vcbam1$3dc6n$1@dont-email.me> (permalink) |
| References | <vc34i0$3rnbg$1@paganini.bofh.team> <vc4oti$1kk40$5@dont-email.me> <vc9kck$2u6ef$1@raubtier-asyl.eternal-september.org> <vc9l5e$2ue0d$1@dont-email.me> <vc9ols$2v5hb$2@raubtier-asyl.eternal-september.org> |
Cross-posted to 2 groups.
On Mon, 16 Sep 2024 19:08:14 +0200
Bonita Montero <Bonita.Montero@gmail.com> boringly babbled:
>Am 16.09.2024 um 18:08 schrieb Muttley@dastardlyhq.com:
>> On Mon, 16 Sep 2024 17:55:02 +0200
>> Bonita Montero <Bonita.Montero@gmail.com> boringly babbled:
>>> Am 14.09.2024 um 21:41 schrieb Chris Ahlstrom:
>>>> DMZ wrote this copyrighted missive and expects royalties:
>>>>
>>>>> This simple program will count characters for you!!
>>>>>
>>>>> #include <stdio.h>
>>>>>
>>>>> int main()
>>>>> {
>>>>> printf(" = %d characters", printf("Hello World!"));
>>>>>
>>>>> return 0;
>>>>> }
>>>>
>>>> Cute.
>>>>
>>>
>>> Nice, but this counts the characters at compile-time:
>>>
>>> std::string_view sv( "Hello World!" );
>>> std::cout << sv << " = " << sv.length() << " characters" << endl;
>>
>> So does sizeof("Hello world!");
>>
>
>But sizeof(string_literal) includes the null-terminating character.
Gosh! Maybe you could do sizeof()-1 then. Just a thought!
Back to alt.comp.lang.c++.misc | Previous | Next — Previous in thread | Next in thread | Find similar
Counting Characters!! DMZ <dmz@dmz.dmz> - 2024-09-14 04:59 +0000
Re: Counting Characters!! Chris Ahlstrom <OFeem1987@teleworm.us> - 2024-09-14 15:41 -0400
Re: Counting Characters!! Mike Terry <news.dead.person.stones@darjeeling.plus.com> - 2024-09-14 22:04 +0100
Re: Counting Characters!! Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-16 17:55 +0200
Re: Counting Characters!! Muttley@dastardlyhq.com - 2024-09-16 16:08 +0000
Re: Counting Characters!! Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-16 19:08 +0200
Re: Counting Characters!! Muttley@dastardlyhq.com - 2024-09-17 07:21 +0000
Re: Counting Characters!! Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-17 13:41 +0200
csiph-web