"pemo" <> writes:
> "jan247" <> wrote in message
> news: oups.com...
>> hi, im new here... um, this code works except that, at the end of the
>> loop, i always get a "Segmentation fault". Can anyone help me on this?
>>
>> using GNU C:
>>
>> ....
[snip]
>> while(getline( &line, &nbytes, fp ) != -1)
[snip]
>
> See what the others have said, plus, use fgets instead of getline.
fgets() is standard, while getline() is a GNU extension, so that's
good advice if you're concerned about portability. However, getline()
does have some advantages over fgets() (I won't go into the details),
so it's perfectly appropriate to use it if portability to non-GNU
implementations isn't a concern.
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.