Re: malloc()/realloc() - have I got this right?
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Wed, 28 May 2008 00:09:43 -0400
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>
and read ggets.c (less code that yours, all standard). Then decide
if you want to use it (I have put it in the public domain) or adapt
it to your purposes.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
** Posted from http://www.teranews.com **
.
- Follow-Ups:
- Re: malloc()/realloc() - have I got this right?
- From: Keith Thompson
- Re: malloc()/realloc() - have I got this right?
- From: Richard Heathfield
- Re: malloc()/realloc() - have I got this right?
- References:
- malloc()/realloc() - have I got this right?
- From: Dave
- malloc()/realloc() - have I got this right?
- Prev by Date: Re: preprocessing statements
- Next by Date: Re: scope of struct
- 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
|