Article View: alt.comp.lang.learn.c-c++
Article #34Re: Return a string in C???
From: Richard Heathfield
Date: Mon, 02 Jun 2003 17:56
Date: Mon, 02 Jun 2003 17:56
23 lines
1867 bytes
1867 bytes
chris wrote:
<snip>
>
>
> you could have the function allocate the buffer and return the length:
>
> int StringFunction (char ** buffer) {
> int bufferSize;
> ...
> *buffer = (char *)malloc(bufferSize);
What does the cast buy you?
And why use int, when malloc takes size_t?
<snip>
--
Richard Heathfield : binary@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Technical Details
Message-ID:
<bbg354$k2n$3@hercules.btinternet.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed!btnet-peer0!btnet-feed5!btnet!news.btopenworld.com!not-for-mailReferences:
<oVDAa.85219$Vi5.2444320@news1.calgary.shaw.ca> <b709e49a.0306020942.3b31389d@posting.google.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1014db,726fa50532a809c2 X-Google-Attributes: gid1014db,public X-Google-Thread: 10d4ba,726fa50532a809c2 X-Google-Attributes: gid10d4ba,public X-Google-Thread: 114592,726fa50532a809c2 X-Google-Attributes: gid114592,public X-Google-ArrivalTime: 2003-06-02 10:57:01 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed!btnet-peer0!btnet-feed5!btnet!news.btopenworld.com!not-for-mail From: Richard Heathfield <dontmail@address.co.uk.invalid> Newsgroups: alt.comp.lang.learn.c-c++,att.lang.c++,comp.lang.c Subject: Re: Return a string in C??? Date: Mon, 2 Jun 2003 17:56:53 +0000 (UTC) Organization: None Lines: 23 Message-ID: <bbg354$k2n$3@hercules.btinternet.com> References: <oVDAa.85219$Vi5.2444320@news1.calgary.shaw.ca> <b709e49a.0306020942.3b31389d@posting.google.com> Reply-To: binary@eton.powernet.co.uk NNTP-Posting-Host: 213.122.225.100 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: hercules.btinternet.com 1054576613 20567 213.122.225.100 (2 Jun 2003 17:56:53 GMT) X-Complaints-To: news-complaints@lists.btinternet.com NNTP-Posting-Date: Mon, 2 Jun 2003 17:56:53 +0000 (UTC) User-Agent: KNode/0.7.1