473,395 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

another c++ i/o questions



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, seemed like it no longer read all of the
data.
Any thoughts on the above would be appreciated.

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

doug

--
Aug 26 '05 #1
1 1115
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
Aug 26 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: fig000 | last post by:
Hi, I'm relatively new to Javascript so please bear with me on what might sound like silly questions. This is what I want to do: I'm working in classic asp (I have to for this project). I...
1
by: Jung Joon Park | last post by:
Hi everyone. I am JJ Park. I got some questions in C++. First of all, my English is not perfect, because I am foreigner. I have got C++ code, which have no syntex error in Visual C++ ver6.0...
75
by: Greg McIntyre | last post by:
I have a Python snippet: f = open("blah.txt", "r") while True: c = f.read(1) if c == '': break # EOF # ... work on c Is some way to make this code more compact and simple? It's a bit...
29
by: Tola | last post by:
In my case of study, my teacher gave me a project, after I analysed the problem I found that I had to used open the file on the other machine? Please help? Thank you in advance. Tola CHROUK
33
by: Partha Protim Roy | last post by:
Hello, I have a Customer form say A to enter/update customer details. In the Form A I have a button which opens another form say B. In the Form B, I am providing user with a option to search...
24
by: =?Utf-8?B?RHIuIFMu?= | last post by:
I am incorporating three existing programs into a new "all in one" program. I have added the three projects to the new all in one project. How do I instruct the new initial menu to launch the main...
0
by: RobAMacAF | last post by:
Here is my prediciment. I have a database with a form. It in the people can pick a main category, then sub category, then it shows a list of questions from that in a sub form. I am trying to find a...
1
by: RobAMacAF | last post by:
Here is my prediciment. I have a database with a form. It in the people can pick a main category, then sub category, then it shows a list of questions from that in a sub form. I am trying to find a...
6
by: rhino | last post by:
Does anyone know where I could get my hands on one or more old DB2 certification exams? I'm especially interested in Exams 700 and 701 but would like to look at others as well. There are links...
31
by: pradeep | last post by:
Hello friends: I have the following code, char* MyClass::MyMethod() { char* ptr = new char; // space for NULL terminator ptr = "hello"; return ptr; delete ptr;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.