Doug Harvey wrote:
> I have a question that hopefully someone here has already figured out.
>
> I have more experience programming in "C", and in order to improve I/O
> throughput we would use setvbuf() to increase the buffer size that
> fread/read used when reading files. It made a pretty big difference.
> I tried the following:
>
> char mybuffer[1000000];
> inp.rdbuf()->pubsetbuf(mybuffer,1000000);
>
> while (getline((inp),line)) {
> ...
>
> but it changed the output,
In what way? What was the output before and what is it after? "Changed"
isn't much to work on.
> seemed like it no longer read all of the
> data.
How much of the data does it read? 10%? 90%? 99.9%? What's missing?
> Any thoughts on the above would be appreciated.
From the archives: pubsetbuf does not guaranteed to turn buffering on.
See this:
http://tinyurl.com/7a9a6 (I searched for 'pubsetbuf')
>
> Also, is the read() function the proper way to read fixed-length records
> using the C++ i/o libraries?
Sure.
Perhaps you could be a good sport and read the FAQ first. Perhaps after
that you would consider following the recommendation of FAQ 5.8...
V