Re: need some help
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Fri, 09 Jun 2006 23:59:46 -0400
Richard Heathfield wrote:
.... snip ...
2) the next stage is to write (or find) a function that can read
an entire line from standard input, reallocating storage as and
when necessary to ensure that there is sufficient room to store
the string. For a very simple way to do this that will suit you
very well, look for Chuck Falconer's ggets() function which,
last I heard, could be found at:
<http://cbfalconer.home.att.net/download/ggets.zip>
3) simply call this function in a loop, assigning each pointer
thus obtained to new[i], where i is your loop counter, running
from 0 to n-1. What will you do if the function returns NULL, to
indicate insufficient storage, or perhaps an absence of input data?
int ggets(char**) returns 0 for success, EOF for eof, and positive
for lack of memory. So a suitable read'em'all loop is:
while (0 == ggets(&buffptr)) { ... }
--
Some informative links:
news:news.announce.newusers
http://www.geocities.com/nnqweb/
http://www.catb.org/~esr/faqs/smart-questions.html
http://www.caliburn.nl/topposting.html
http://www.netmeister.org/news/learn2quote.html
.
- Follow-Ups:
- Re: need some help
- From: Richard Heathfield
- Re: need some help
- References:
- need some help
- From: ash
- Re: need some help
- From: Richard Heathfield
- need some help
- Prev by Date: Re: Structure of functions
- Next by Date: Re: Why the C committee doesn't provide an implementation when the standard is published?
- Previous by thread: Re: need some help
- Next by thread: Re: need some help
- Index(es):
Relevant Pages
|