Mail Archives: djgpp/2001/11/08/14:34:42
In article <9sei6v$8j9$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE>, broeker AT physik DOT rwth-
aachen.de says...
> Robert Neinast <neinast AT worldnet DOT att DOT net> wrote:
>
> > This is driving me nuts. In C, I'm doing simple getchars from
> > stdin and writing to a file, and it keeps getting truncated.
> > Anybody have any ideas what the heck I'm doing wrong????
>
> In DOS, text files have a different line end ("\r\n" instead of a
> simple "\n", in C terms), and Ctrl-Z is interpreted as an end-of-file
> marker. Stdin is opened in *text* mode, by default.
>
> To get around this, you have to set the file handling mode of stdin to
> binary:
>
> setmode(fileno(stdin), O_BINARY);
>
> See the docs on these functions for details.
OK, I was right on the verge. My original had it reading
from a file, which I opened with fopen(filename, "r").
Then in trying to isolate the problem, I converted to stdin
and still had the problem. Then (I know, wrong order) I
read the docs and for some silly reason modified
my *write* open to fopen(filename, "w") to fopen(filename, "wb").
So, I was on the right trail; just not thinking hard enough.
Any way to change EOF to ctrl-D like real UNIX (and to reset
interrupt)? I notice that there is no bash command like stty.
Many thanks for the assistance.
Bob
--
. . . and shun the Frumious Bandersnatch
Robert A. Neinast
Pickerington, OH
- Raw text -