I'm running this on my Linux and I'm getting just what I should be getting: the same file without new line characters and "qwert"
printed to stdout. If you're getting something else, it must be an issue with CR/LF translation. Try replacing "r"
and "w"
with "rt"
and "wt"
, respectively.
Two PS comments:
The given program works (with or without
"rt"
) on mygcc
4.7.2 on Linux, provided that line terminators in the input file are converted from CRLF to LF. This is reasonable when you move a text file from Windows to Linux and can be done, e.g., with thefromdos
tool.It is true that the C standard (section 7.19.5.3, p. 271, for ISO C99, or section 7.21.5.3, p. 306, for ISO C2011) does not require
"t"
for text files (so, conforming implementations need not implement it), but it seems that some implementations work differently.