Deutsch   English   Français   Italiano  
<usgl6d$1rnlb$3@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.nobody.at!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: vallor <vallor@cultnix.org>
Newsgroups: comp.os.linux.advocacy
Subject: Re: OT programming challenge: fastest/best/shortest C program to
 jumble a sentence, then restore it
Date: Sat, 9 Mar 2024 03:31:26 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <usgl6d$1rnlb$3@dont-email.me>
References: <65e9cad3$0$4689$882e4bbb@reader.netnews.com>
	<l4ufsbF9kdnU4@mid.individual.net> <usf2m9$1n0jh$2@dont-email.me>
	<l518d6FmepqU1@mid.individual.net> <usfs1a$1svs6$1@dont-email.me>
	<usft59$1t70f$1@dont-email.me> <l522g2FqgibU6@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 9 Mar 2024 03:31:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ab4e216fb12235b831fdc816a1885311";
	logging-data="1957547"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19du2s4MaFX+DgpjIA6g5Tk"
User-Agent: Pan/0.155 (Kherson; c0bf34e gitlab.gnome.org/GNOME/pan.git;
 x86_64-pc-linux-gnu)
Cancel-Lock: sha1:nIr943MUWNxzzlqerWIfgM2sk4Q=
X-Face: \}2`P"_@pS86<'EM:'b.Ml}8IuMK"pV"?FReF$'c.S%u9<Q#U*4QO)$l81M`{Q/n
 XL'`91kd%N::LG:=*\35JS0prp\VJN^<s"b#bff@fA7]5lJA.jn,x_d%Md$,{.EZ
Bytes: 2360

On 9 Mar 2024 03:14:10 GMT, rbowman <bowman@montana.com> wrote in
<l522g2FqgibU6@mid.individual.net>:

> On Fri, 8 Mar 2024 15:41:13 -0500, DFS wrote:
> 
>> Sorry.  That's ALL from a crlf inserted by the newsreader.  It compiled
>> cleanly after I took it out.
> 
> Yup...
> 
> In production code I'd likely do
> 
> char* sentence;
> 
> sentence = strdup("Once you try it, you'll see it doesn't need spice.");
> if (sentence == NULL) {
>     printf("strdup() failed: %s", strerror(errno));
>     return -1;
> }

Seems like a lot of work that could be handled by
char sentence[] = "initializer";

Am I missing something?

> 
> Admittedly is the implied malloc() failed the odds of it printing
> anything aren't great but might as well try. I probably would use
> strtok_r() in production if there was a remote possibility that there
> would be another nested strtok(). That's ruined more than one
> programmer's day.
> 

-- 
-v