From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: Pascal Obry Newsgroups: comp.lang.ada Subject: Re: Returning a string from C Date: Thu, 23 Jul 2015 08:41:53 +0200 Organization: Home - http://www.obry.net Message-ID: <1437633713.28927.0.camel@obry.net> References: <27cd219d-fff7-4c2a-90c7-ec10a917b4cb@googlegroups.com> Reply-To: pascal@obry.net NNTP-Posting-Host: PtI8ITE9pEcKelfB/7Em5g.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Complaints-To: abuse@aioe.org X-Mailer: Evolution 3.16.3-1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:27002 Date: 2015-07-23T08:41:53+02:00 List-Id: Le mercredi 22 juillet 2015 =C3=A0 19:20 -0700, NiGHTS a =C3=A9crit : > I am having some difficulty with returning a string from a C=20 > function. >=20 > Say I have the following C function: >=20 > void Return_Hello (char *inout_Test_String ) { > strcpy( inout_Test_String, "Hello World" ); > } I would probably also pass the string length here and use strlcpy instead to avoid any memory corruption. --=20 Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://v2p.fr.eu.org http://www.obry.net gpg --keyserver keys.gnupg.net --recv-key F949BD3B