| Deutsch English Français Italiano |
|
<20250319124050.00000b28@yahoo.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Michael S <already5chosen@yahoo.com> Newsgroups: comp.lang.c Subject: Re: Suggested method for returning a string from a C program? Date: Wed, 19 Mar 2025 12:40:50 +0200 Organization: A noiseless patient Spider Lines: 32 Message-ID: <20250319124050.00000b28@yahoo.com> References: <vrd77d$3nvtf$2@dont-email.me> <vre5gt$jkpr$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Date: Wed, 19 Mar 2025 11:40:50 +0100 (CET) Injection-Info: dont-email.me; posting-host="53b605ccedb1da03e7216ffdd1a8dc82"; logging-data="625406"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+xDz2EAlvElH7uaudoI9SResQTFo7fP2c=" Cancel-Lock: sha1:MyXuyweArqc9i/My28kHcBjmGa0= X-Newsreader: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32) On Wed, 19 Mar 2025 10:15:58 +0000 bart <bc@freeuk.com> wrote: > On 19/03/2025 01:38, DFS wrote: > >=20 > > I'm doing these algorithm problems at > > https://cses.fi/problemset/list/ > >=20 > > For instance: Weird Algorithm > > https://cses.fi/problemset/task/1068 =20 >=20 > This is related to the Collatz Conjecture. What's weird is not=20 > mentioning it. Thank you. Wikipedia article about Collatz Conjecture is a good reading. >=20 >=20 > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 len =3D strlen(result); > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 sprintf(result + len, "%d ", n); =20 >=20 > And what's odd here is collating the results in a string (especially=20 > when the possible number of steps is unknown). Why not just print it=20 > straight to the console? >=20 >=20 OP got it further down the thread.