about filehandling

T

TVS

file handling in c++ using ifstream and ofstream is creating a problem
when i wanted to write to a file using <ofstream>.write() member
function. When I try to retrieve it back using an read() memeber for
an ifstream object i am not able to find any data in the object. Can
you tell me better ways to store into files and retrieve from the files.
 
K

Karl Heinz Buchegger

TVS said:
file handling in c++ using ifstream and ofstream is creating a problem
when i wanted to write to a file using <ofstream>.write() member
function. When I try to retrieve it back using an read() memeber for
an ifstream object i am not able to find any data in the object. Can
you tell me better ways to store into files and retrieve from the files.

Please show some test code, which gives you troubles.
You made a mistake somewhere and talking about
actual code is a good way to show you, where you went
wrong.
 
T

Tim Love

TVS said:
file handling in c++ using ifstream and ofstream is creating a problem
when i wanted to write to a file using <ofstream>.write() member
function. When I try to retrieve it back using an read() memeber for
an ifstream object i am not able to find any data in the object. Can
you tell me better ways to store into files and retrieve from the files.
Can you send a little (minimal) file to illustrate the problem?
Sounds like a buffering issue.
 
D

Dietmar Kuehl

TVS said:
file handling in c++ using ifstream and ofstream is creating a problem
when i wanted to write to a file using <ofstream>.write() member
function. When I try to retrieve it back using an read() memeber for
an ifstream object i am not able to find any data in the object.

I would guess that you don't open the files in binary mode: this may
indeed mess up some the data. Otherwise, I would expect that saving
PODs in binary mode should work as long as you stay on the same
machine,
the same compiler version, etc. In general, you should, however, format
your data even when using a binary format.

What exactly is your problem and what does your code look like: with
the information you provided we cannot do much more than guess what
you try to do.
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top