Re: How to take in a string of any size?
From: William L. Bahn (william_at_toomuchspam.net)
Date: 08/23/04
- Next message: Richard Pennington: "Re: How to take in a string of any size?"
- Previous message: Flash Gordon: "Re: use of serial and parrallel port using C"
- In reply to: Gordon Burditt: "Re: How to take in a string of any size?"
- Next in thread: SM Ryan: "Re: How to take in a string of any size?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 23 Aug 2004 06:03:18 -0600
"Gordon Burditt" <gordonb.4s7ny@burditt.org> wrote in message
news:cgbovu$f0j@library1.airnews.net...
> >IIRC, the OP didn't specify that the input string was coming
from
> >a file.
> >
> >If it IS in a file, then the solution is trivial - scan the
file
> >and count the number of characters you are going to read in
then,
> >allocate the correct amount of memory, rewind the file, and
read
> >the contents into the allocated memory.
>
> (1) nobody said the string started at the beginning of the
file.
True - what I meant was rewind the file to the point where you
started reading it from. I didn't mean rewind as in use rewind()
to go all the way to the start. I was making a comment in English
and relying on people to comprehend the meaning from context (not
that I was consciously doing that) and my use of a common word
that happens to be the same as a function name caused confusion.
Sorry.
> (2) files are not necessarily rewindable, and even if they are,
> they may not be rewindable efficiently (consider a deck of
punch
> cards or paper tape. Even magnetic tape doesn't rewind very
fast.)
> Then there's these things that sorta look like files that
aren't,
> like pipes and sockets.
Again, some common sense and context are required. Almost any
piece of code is going to have problems under some circumstances.
If the file is not rewindable or, more specifically, if the
position in the file can not be fetched and later returned to,
then something else needs to be done.
- Next message: Richard Pennington: "Re: How to take in a string of any size?"
- Previous message: Flash Gordon: "Re: use of serial and parrallel port using C"
- In reply to: Gordon Burditt: "Re: How to take in a string of any size?"
- Next in thread: SM Ryan: "Re: How to take in a string of any size?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]