Re: Variable-sized lines of text in linked list
- From: "Bartc" <bc@xxxxxxxxxx>
- Date: Fri, 29 Feb 2008 15:31:18 GMT
"Bill Reid" <hormelfree@xxxxxxxxxxxxxxxx> wrote in message
news:ezKxj.679254$kj1.213468@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Scottman <FonzoCool@xxxxxxxxx> wrote in message
news:1fe49f6a-2abf-419d-9008-99ee0fc6cee7@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am trying to read a text file into memory without any knowledge of
how long each line will be. I am looking to store each line in a
linked list structure, however, I am unsure of how to dynamically
allocate space for each line.
Maybe you don't have to malloc each line, but rather just the entire
file, with pointers to the start of each line, and replace each newline
with a terminating null (this decision will impact how easily you can
process the lines after you've stored them this way, but just throwing
out an idea that doesn't seem to be getting much play here).
Reading an entire file into memory is an admirable idea, but is frowned on
in this newsgroup for various reasons: the size of a file is impossible to
determine, or could change while you're reading the file, or because it
might be a 100GB monster you therefore should never attempt this even for
tiny files.
That doesn't mean you shouldn't do it; just keep quiet about it here :-)
--
Bart
.
- Follow-Ups:
- Re: Variable-sized lines of text in linked list
- From: CBFalconer
- Re: Variable-sized lines of text in linked list
- References:
- Variable-sized lines of text in linked list
- From: Scottman
- Re: Variable-sized lines of text in linked list
- From: Bill Reid
- Variable-sized lines of text in linked list
- Prev by Date: Re: Variable-sized lines of text in linked list
- Next by Date: Re: dual core and c
- Previous by thread: Re: Variable-sized lines of text in linked list
- Next by thread: Re: Variable-sized lines of text in linked list
- Index(es):
Relevant Pages
|