Re: Reading a table



Bill Reid wrote:
CBFalconer <cbfalconer@xxxxxxxxx> wrote in message
Bill Reid wrote:
Roland Pibinger <rpbg123@xxxxxxxxx> wrote in message

... snip ...

- whithout static FILE

Possibly, but the idea here is just to read a single file and
then close it right up...

- for arbitrary long lines (no hard-coded maximum line lenght)

Yes, but again the idea here is we KNOW the maximum size> of our
file lines,

However, some people want to copy files without worrying about line
length. With ggets (and fggets) you can handle this with ease, as
in the following:

[1] c:\c\junk>cc -o fcopylns.exe ggets.o junk.c

[1] c:\c\junk>fcopylns <junk.c
#include <stdio.h>
#include <stdlib.h>
#include "ggets.h"

int main(void) {
char *line;

while (0 == ggets(&line)) {
puts(line);
free(line);
}
return 0;
} /* main, fcopylns */

Note the complexity. You can get the source etc. for ggets at:

<http://cbfalconer.home.att.net/download/ggets.zip>

Sure, something like that might come in handy in some situations,
but I actually take a somewhat different tack for parsing out text
"tables" with potentially (unpredictably) HUGE "field" sizes.

Try out ggets. It will handle ANY size line. I deliberately
designed it to replace gets, with the usage simplicity, but no
worry about over-run. It's primary use is in interactive work, but
the efficiency is not bad for general use.

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.



--
Posted via a free Usenet account from http://www.teranews.com

.



Relevant Pages

  • Re: Reading a table
    ... Bill Reid wrote: ... snip ... ... but the idea here is just to read a single file and ... With ggets you can handle this with ease, ...
    (comp.lang.c)
  • Re: Determine the size of malloc
    ... Eligiusz Narutowicz wrote: ... snip ... ... ggets() is an example of how to solve ... the OP's problem with portable code. ...
    (comp.lang.c)
  • Re: Puzzle!
    ... snip ... ... your format? ... it's not homework. ... ggets is non-standard, available on my page. ...
    (comp.lang.c)
  • Re: Why is it dangerous?
    ... ggets really did overcome this obstacle, ... In practice, what ggets ...
    (comp.lang.c)