another c++ i/o questions

D

Doug Harvey

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/
throughput we would use setvbuf() to increase the buffer size tha
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, seemed like it no longer read all of th
data
Any thoughts on the above would be appreciated

Also, is the read() function the proper way to read fixed-length record
using the C++ i/o libraries
Thanks in advance of course

dou

--
 
V

Victor Bazarov

Doug said:
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
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top