假设我向ostream::write发送了一个大缓冲区,但实际上只有开头部分写入成功,其余部分没有写入
int main()
{
std::vector<char> buf(64 * 1000 * 1000, 'a'); // 64 mbytes of data
std::ofstream file("out.txt");
file.write(&buf[0], buf.size()); // try to write 64 mbytes
if(file.bad()) {
// but suppose only 10 megabyte were available on disk
// how many were actually written to file???
}
return 0;
}
什么 ostream 函数可以告诉我实际写入了多少字节?