Re: fscanf
- From: Paul <nospam@xxxxxxxxxx>
- Date: Sun, 17 Aug 2008 21:37:58 -0400
Bill Cunningham wrote:
"Ian Collins" <ian-news@xxxxxxxxxxx> wrote in message news:6grvbqFhb2hlU5@xxxxxxxxxxxxxxxxxxxxx
So what does your documentation well you about append mode?It just says append is a possible mode with a+ also which is append-read mode. Plus this book tells me that garbage about using t if I want for text mode. I know that's not portable stdc.
http://www.cppreference.com/stdio/fopen.html
Is my main online reference. I've been thinking my trouble is in fscanf. It might be in fopen's mode.
Bill
http://linux.die.net/man/3/fopen
"The argument mode points to a string beginning with one of the following
sequences (Additional characters may follow these sequences.):
a Open for appending (writing at end of file). The file is created if
it does not exist. The stream is positioned at the end of the file. <---- yikes
"
http://linux.die.net/man/3/fscanf
"Return Value
These functions return the number of input items successfully matched and assigned,
which can be fewer than provided for, or even zero in the event of an early matching
failure.
The value EOF is returned if the end of input is reached before either the first
successful conversion or a matching failure occurs. EOF is also returned if a read
error occurs, in which case the error indicator for the stream (see ferror(3)) is
set, and errno is set indicate the error."
Defensive programming, means checking the values returned by things like fscanf.
Wouldn't you be curious, whether fscanf converted zero, one, or two items ? If the
answer is not two, then X or Y could contain bogus information. And if an end of
file was encountered, you'd probably want to know about that also. There are many
possible outcomes, when handling file I/O.
Paul
.
- Follow-Ups:
- Re: fscanf
- From: Ian Collins
- Re: fscanf
- From: Bill Cunningham
- Re: fscanf
- References:
- fscanf
- From: Bill Cunningham
- Re: fscanf
- From: Anand Hariharan
- Re: fscanf
- From: Bill Cunningham
- Re: fscanf
- From: Bill Cunningham
- Re: fscanf
- From: Ian Collins
- Re: fscanf
- From: Bill Cunningham
- fscanf
- Prev by Date: Re: Amount OF Memory...,
- Next by Date: Re: fscanf
- Previous by thread: Re: fscanf
- Next by thread: Re: fscanf
- Index(es):
Relevant Pages
|