Question with binary IO with g77 on windows and Bug with fputc
Martin Kahlert
martin.kahlert@mchp.siemens.de
Mon Jan 17 23:39:00 GMT 2000
Quoting toon@moene.indiv.nluug.nl (toon@moene.indiv.nluug.nl):
> You wrote:
>
> > I have a problem with g77 on WinNT (mingw) regarding binary output.
>
> > OPEN(77,FILE='TEST',ACCESS='SEQUENTIAL',FORM='FORMATTED')
> > WRITE(77,'(A1,$)') CHAR(10)
> > CLOSE(77)
> > END
>
> Note that this is *not* binary output (which is not really defined in
> Fortran - what you want is probably just "I/O without frills").
You are right, what i really want is to output data in fortran, like
i would do fwrite(buffer,...) in C. (My application has to write
its results into a binary file.
My (wrong) solution to that, was the output via the A format specifier.
This application was ported recently to WinNT
(using a Linux to Mingw32 cross compiler). Since the tool to
view the results was only available on Unix people had to use
other output formats (e.g. gnuplot) and the problem didn't show up.
Sorry that i misled you (and others) by this term.
> FORMATTED I/O results in text files, and apparently on a Windows NT
> machine this means that linefeeds are transformed into carriage retun
> line feed pairs (so that you can read the resulting text file in, e.g.
> NotePad).
>
> The following program (although somewhat contrived) probably does what
> you want:
>
> OPEN(77,FILE='TEST',ACCESS='DIRECT',FORM='UNFORMATTED',RECL=1)
> WRITE(77,REC=1) CHAR(10)
> CLOSE(77)
> END
Thanks very much for this solution. I will use it instead.
Actually i tried the same solution, but forgot the REC=1 in the
write statement, which put the record size into the file :-(
Thanks again for your very helpful reply,
Martin.
--
The early bird gets the worm. If you want something else for
breakfast, get up later.
More information about the Gcc-bugs
mailing list