----- Original Message -----
From: "Kubol" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, March 13, 2001 12:48 AM
Subject: Re: [PHP] fscanf


> 01-03-13 05:00:01, "Yasuo Ohgaki" <[EMAIL PROTECTED]> wrote:
>
> >I think fscanf() is line oriented in C, isn't it? (I haven't used fscanf()
for a
> >long time, I'm not 100% sure w/o reference.)
> no, i'm sure in c fscanf reads the next string available, not first string in
next line
> >Your $buffer should only have "lenin".
> i agree. in first iteration buffer should contain "lenin", but in second the
content should be "lives", not "forever",
> but is "forever" and i dont
> know why and i'm angry about it :-)
> >while (fscanf($file,"%s %s",$buf1,buf2))
> >You should get "lives" in $buf2.
> i agree again, but i dont know how many stings do i have in one line.
therefore i cant use
> fscanf($file,"n*%s",n*some_variables);
> besides it looks terrible... :-)

Now I understand why you are wondering.
In C, you can get "words" in file with your code, but not in PHP. fscanf()
between C and PHP is not identical when I made a simple test codes for both. It
seems PHP's fscanf() advances file pointer to end of line while C's fscanf()
must be done by programmers like fscanf(fp,"%*[^\n]"). In most cases,
programmers want to move file pointer to the end of line. Maybe that's why PHP's
fscanf() does this.

We cannot expect PHP functions works just like C/C++/Java since it is different
languange even is name of the function is the same. I guess what you want to do
is getting all words from a file using fscanf(), but it seems it is not possible
with PHP's fscanf(). (Or is it a bug? Anyone?)

Functions that have the same name in C better to be behaive just like C in PHP
for C programmers. (but may not be good for non-C programmers.) I'm relatively
new to PHP, so I don't know historical reason why some functions does not
behaive like C. I see a lot of differences PHP and C, I think this is the way it
is.

How about a start new thread if you still curious about fscanf() behaviour?
Someone may be able to give better explaination.

Regards,
--
Yasuo Ohgaki

> regards,
> jakub zytka
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to