Re: fscanf



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
.



Relevant Pages

  • Error using fscanf -- Size must be of type double
    ... Error using ==> fscanf ... My program can run but after I append a few more lines of code to the program. ... The Matlab said that the error is at this line ... Thank for you suggestion. ...
    (comp.soft-sys.matlab)
  • Re: Adding to binary files
    ... Is it possible in ProDOS to either combine file segments on ... you should be able to append to a file by doing OPEN ... SET_EOF past the current EOF and do a SET_MARK between the old EOF ... jmatthews at wright dot edu ...
    (comp.sys.apple2.programmer)
  • Re: how to write to a file without race condition
    ... >>No, each of them will atomically seek to the current EOF, append their ... then the next one will write at the new EOF. ... (James Antill *agreed* with it, ... to set O_APPEND rather than using lseek(). ...
    (comp.unix.programmer)
  • Simple RMS question
    ... I want to open a sequential file using RMS, append a single line and close it. ... When calling SYS$PUT I get the error %RMS-F-NEF which is not positioned to EOF on $PUT if the file is nonblank. ...
    (comp.os.vms)
  • Re: leading null characters produced in script...
    ... :> When a file is opened in append mode, there is an implied seek to EOF ... when your log rotation truncates the ... :> continuing at its current offset. ...
    (comp.os.linux.misc)