How large is the stream buffer?

L

Lambda

As I know, when I use ifstream and ofstream to read and write file,
it will use a stream buffer internally.
How large is the stream buffer?

If I want to write a large file, need I define a stream buffer myself?
In what situation, user-defined stream buffer is useful?
 
J

James Kanze

As I know, when I use ifstream and ofstream to read and write file,
it will use a stream buffer internally.
How large is the stream buffer?

About so big.

It depends on the implementation, and will often be optimized
for the system you're running under.
If I want to write a large file, need I define a stream buffer
myself?
No.

In what situation, user-defined stream buffer is useful?

Any time the non-standard ones aren't sufficient. The most
frequent use is probably filtering streambuf's; it's hard to
imagine an application that doesn't use at least one (if only
for log dispatching). Non-filtering user written streambuf's
are used to interface with sockets, pipes, raw memory, or just
about anything else besides ordinary files and std::strings.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top