Re: malloc()/realloc() - have I got this right?
- From: Richard Heathfield <rjh@xxxxxxxxxxxxxxx>
- Date: Thu, 29 May 2008 18:45:56 +0000
CBFalconer said:
Dave wrote:
I'm teaching myself C by working my way through Steve Summit's
tutorial (http://www.eskimo.com/~scs/cclass/cclass.html). In one
of the questions (assignment 6, exercise 7), you have to write a
function to read lines of arbitrary length from the command line,
using malloc() and realloc() to allocate the necessary memory to
hold the lines. I came up with this:
Instead of all that just get ggets.zip from:
<http://cbfalconer.home.att.net/download/ggets.zip>
Be aware, if you do so, that the above routine has what some people
consider to be serious design flaws. And of course you'll learn more by
writing your own than you will by pinching someone else's.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.
- Follow-Ups:
- Re: malloc()/realloc() - have I got this right?
- From: CBFalconer
- Re: malloc()/realloc() - have I got this right?
- References:
- malloc()/realloc() - have I got this right?
- From: Dave
- Re: malloc()/realloc() - have I got this right?
- From: CBFalconer
- malloc()/realloc() - have I got this right?
- Prev by Date: Re: Determine the size of malloc
- Next by Date: Re: replace substring
- Previous by thread: Re: malloc()/realloc() - have I got this right?
- Next by thread: Re: malloc()/realloc() - have I got this right?
- Index(es):
Relevant Pages
|