in reply to bin mode file copy

Both Corion & kennethk, quite correctly, refer you to read.

However, IMO, what the aforementioned doc doesn't explicitly tell you is that (if LENGTH is specified) the call to read() should attempt to read no more than LENGTH bytes before returning i.e if the number of bytes successfully read from the file is less than LENGTH bytes, then the call will still be deemed successful (the call always returns the number of bytes actually read - which is stated in the doc).

Update

Wording modified in (what I think is) in line with ikegami's observation.

A user level that continues to overstate my experience :-))

Replies are listed 'Best First'.
Re^2: bin mode file copy
by ikegami (Patriarch) on Mar 16, 2009 at 16:48 UTC

    This isn't the first time someone suggested adding the word "max", but it would be wrong to do so.

    If someone were to complete "I attempted to read a max of 10,000 chars, but", I would expect to hear "I read 15,000." A failed attempt is a failure to match the "max" constraint (going over).

    It would probably be useful for the docs to specify that falling short of the goal isn't considered an error. And that read will actually wait for the desired number of chars to arrive (absent eof or error). But it's incorrect to use "max" as you've used it.