🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #35

Re: Return a string in C???

#35
From: chris
Date: Tue, 03 Jun 2003 12:45
31 lines
2291 bytes
"Richard Heathfield" <dontmail@address.co.uk.invalid> wrote in message
news:bbg354$k2n$3@hercules.btinternet.com...
> 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

my compiler complains about casting a void * to a value without doing it
explicitly, and i would normally use an unsigned, but didn't think of it at
the time because it was just a quick response

chris
Technical Details
Message-ID: <3M0Da.83479$%e.4559628@twister.austin.rr.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-east.nntpserver.com!nntpserver.com!news-west.rr.com!cyclone.austin.rr.com!twister.austin.rr.com.POSTED!53ab2750!not-for-mail
References: <oVDAa.85219$Vi5.2444320@news1.calgary.shaw.ca> <b709e49a.0306020942.3b31389d@posting.google.com> <bbg354$k2n$3@hercules.btinternet.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: 114592,726fa50532a809c2
X-Google-Attributes: gid114592,public
X-Google-Thread: 10d4ba,726fa50532a809c2
X-Google-Attributes: gid10d4ba,public
X-Google-ArrivalTime: 2003-06-03 05:46:40 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-east.nntpserver.com!nntpserver.com!news-west.rr.com!cyclone.austin.rr.com!twister.austin.rr.com.POSTED!53ab2750!not-for-mail
From: "chris" <ChrisCummings@hot.rr.com>
Newsgroups: alt.comp.lang.learn.c-c++,att.lang.c++,comp.lang.c
References: <oVDAa.85219$Vi5.2444320@news1.calgary.shaw.ca> <b709e49a.0306020942.3b31389d@posting.google.com> <bbg354$k2n$3@hercules.btinternet.com>
Subject: Re: Return a string in C???
Lines: 33
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <3M0Da.83479$%e.4559628@twister.austin.rr.com>
Date: Tue, 03 Jun 2003 12:45:51 GMT
NNTP-Posting-Host: 24.162.154.83
X-Complaints-To: abuse@rr.com
X-Trace: twister.austin.rr.com 1054644351 24.162.154.83 (Tue, 03 Jun 2003 07:45:51 CDT)
NNTP-Posting-Date: Tue, 03 Jun 2003 07:45:51 CDT
Organization: Road Runner - Texas