By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,434 Members | 2,884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,434 IT Pros & Developers. It's quick & easy.

ios::binary issue

P: 10
Hi, I'm a little stuck,

I basically need to copy all the information within a specific file in Temp and append it to a file in another location.

I'm not having any problems with smaller size log files stored within temp foldier and everything reads and appends perfectly, however when i try to read and append from IS12Install.log file in Temp all it appends to my destination file is:

=
and a whole bunch of empty lines

I believe that this is an encoding issue..
I thought that i might solve this by using the binary read and binary write(append) ios::binary to get around this issue...

1) Why is this happening? I've noticed that the log file is 2.5mb might this be the issue?

2) Will ios::binary solve this issue?

3) If i do read and write(append) binary what i need to do to convert the binary back to letters before i write(append) the information?

4) Any other ideas of what might be happening and how to solve this issue?

Here is a chunk of my code:

//OPEN BOTH SOURCE AND DESTINATION FILES FOR READING AND WRITING/APPENDING
fstream file_in(SrcFile,ios::in);
fstream file_out(DestFile,ios::app);

//READ FROM SOURCE FILE
//APPEND EVERYTHING TO DESTINATION
char str[2000];

while(!file_in.eof())
{
file_in.getline(str,2000);
file_out << "\n" << str;
}
file_out << endl;

//CLOSE BOTH SOURCE AND DESTINATION FILES
file_in.close();
file_out.close();

Thanks in advance
Alex
Sep 14 '06 #1
Share this Question
Share on Google+
1 Reply


P: 10
Ok apparently i found out more about what is happening:

the .log file that i'm having problems with is in Unicode... so i have to read the Unicode line by line convert it to normal characters and write it to my Destination Log File...

I was told that unless i use cstring i won't be able to read the Unicode correctly...is this true?

Also what would be the best way going about doing what i described?

Thanks for all the help

Alex
Sep 15 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.