Re: stream io in c



Ron Ford wrote:

.... snip ...

I've tried some variations with this.

int i;
for (i = 0; i <= UCHAR_MAX; i++) putchar (i);

When stdout is redirected to a file, I get a file of size 257
bytes. I wanted to see if that would also be the case if I
created the file from source, but I've got type mismatches here:

The system you are using affects this. Some will expand '\n' to cr
and lf, others just to lf, others to just cr, or even a line with a
length flag. Some will insist on adding an EOF marker, some wont.
If your system is ASCII you wrote a '\n' with the 11th character.
You wrote a '\0' with the first.

What you ARE guaranteed is that you get back what you wrote
(assuming proper file modes in the open argument).

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.


.



Relevant Pages