Well, finally found an explanation and a solution: calling fgets()
twice. Because if there's no length limit supplied (and it's not EOF)
when calling the function, it continues reading until it finds the
first newline character. So calling fgets() again will ensure that it
will read from the
On 30 May 2008 02:56, Usamah M. Ali advised:
So you're confirming that fgets() doesn't necessarily read a whole
line? This user note existed on the manual's page of fgets() since
2004 and nobody deleted it or commented about:
rstefanowski at wi dot ps dot pl
12-Aug-2004 09:03
Take note
Usamah M. Ali wrote:
Hello,
I have a function that picks up a random entry from a file consisting
of city names, each name on a separate line. The random value is
generated by rand() before fseek()ing to the position determined by
it. The problem is that when using fgets() to get a random
On Fri, May 30, 2008 at 3:38 AM, Chris [EMAIL PROTECTED] wrote:
fseek doesn't go to the start of a line, it goes to a particular byte -
so that's where the problem lies (not with fgets). There's no function
(that I could see) which would go to the start of the line based on that
offset (I
I just need to figure out why when using fgets() with fseek()
rand(), the script returns partial strings form the city names.
Because fseek doesn't necessarily put you at the start of a line.
It puts you anywhere (which could be the start, middle, 3 chars from the
end) according to the
On Fri, May 30, 2008 at 4:21 AM, Chris [EMAIL PROTECTED] wrote:
I just need to figure out why when using fgets() with fseek()
rand(), the script returns partial strings form the city names.
Because fseek doesn't necessarily put you at the start of a line.
It puts you anywhere (which could
6 matches
Mail list logo