Re: malloc()/realloc() - have I got this right?



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
.



Relevant Pages

  • Re: malloc()/realloc() - have I got this right?
    ... I'm teaching myself C by working my way through Steve Summit's ... of the questions (assignment 6, exercise 7), you have to write a ...
    (comp.lang.c)
  • Re: Resource Leveling
    ... Thanks again for your response Steve. ... him in the View / Resource Sheet - and under Resource Availability inserted ... I've added Joe to the resource sheet and made him available for November ... change the assignment levels once you have set them. ...
    (microsoft.public.project)
  • Re: Assignment dates not moving with task dates
    ... There are some dependencies but as Steve has noted we are using project to ... apart from how the resource assignment loads are distorted by the assignment ... That's what drives ...
    (microsoft.public.project)
  • Re: Conference
    ... far as assignment is concerned. ... (at least in the wards I've lived in) ... If they prefer a smaller or larger VT route, ... Teaching is never "Done". ...
    (soc.religion.mormon)
  • Re: Is Michael Glasser being watched? - WAS- Re: Kernel Panic
    ... With Steve in my KF his desperation will only get more extreme. ... If anyone cares, I am currently teaching at one college, and will be ... do private tech support and tutoring... ... Sure, Snit... ...
    (comp.sys.mac.advocacy)