ifstream.read() vs. ifstream.readsome() in MSVC++7.1

北城以北 提交于 2019-12-06 02:23:56

readsome() is there to make non blocking reads, as what precisely that means is implementation defined (or defined by your custom streambuf member showmanyc()), behaviour can vary. Both seem correct to me.

And the assertion "assert(buf1 == buf2);" fails when compiling in debug mode because buf1 and buf2 were only told to reserve memory (that is only to allocate memory, not to initialize it), and the operator == actually compares two buffers having undefined values.

As for "read(...)" and "readsome(...)", my advice is to stick with "read(...)" for most cases.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!