-
readsome() doesn't work
Maybe it's just me again, but readsome never seems to actually read anything, and always returns 0. For example:
Code:
#include <iostream>
#include <fstream>
int main()
{
std::ifstream in("test.txt"); //test.txt exists and contains text
if (!in.good())
std::cout<<"Error opening file!";
char buf[11]={0};
while (true)
{
int count = in.readsome(buf,10);
if(!count)
break;
std::cout<<count<<' '<<buf<<std::endl;
}
}
If I run that example, I get no output at all (it breaks the first time the loop runs). This isn't really a problem (I can just use read() and gcount()), but I was wondering if it's really broken, or if I'm somehow doing something wrong (using VS .NET 2003 btw).
-
readsome() doesn't work on VC++ 6 either. It didn't appear on the popup member list after I typed "in.", so I don't think it's supported. Supposedly readsome() examines an iostream object's "internal buffer" so that you can read from the internal buffer before the read operation, which is filling the buffer, finishes. Apparently under the C++ standards, compilers are allowed to return 0 from readsome() to prevent you from mucking about inside the iostream object.
Try read() and gcount() instead.