3 ms·
You’d return -1. A successful read won’t read negative bytes. The non-error value remains useful.
by 9rx 2y ago
You’d return -1. A successful read won’t read negative bytes. The non-error value remains useful.
- int_19h 2y agoThat's actually a great example. Note that it is a distinct sentinel error value that needs to be checked for (contrary to your initial assertion), and if you forget to do it, you'll just end up with garbage. But also, let's say the read function in question is named ReadInt32. Then what does it return on error?