K
kieran
Hi,
I'm using fstream.get to read in a character from a file, then print it
on the screen. I have a file called test.log that contains "Hello,
World!", but when I try and print the contents out on the screen I get
"Hello, World!!". The following is the code (please ignore all
wxWidgets classes):
void SystemBackupFrm::compress()
{
using namespace std;
const wxString dir = "C:\\Backups\\";
wxFFileOutputStream out(dir + "files.zip");
wxZipOutputStream zip(out);
wxTextOutputStream data(zip);
fstream file1("C:\\test.log", ios::in );
zip.PutNextEntry("C:\\test.log");
char t;
while(file1.good())
{
file1.get(t);
cout << t ;
data << t;
}
file1.close();
}
Cheers,
Kieran
I'm using fstream.get to read in a character from a file, then print it
on the screen. I have a file called test.log that contains "Hello,
World!", but when I try and print the contents out on the screen I get
"Hello, World!!". The following is the code (please ignore all
wxWidgets classes):
void SystemBackupFrm::compress()
{
using namespace std;
const wxString dir = "C:\\Backups\\";
wxFFileOutputStream out(dir + "files.zip");
wxZipOutputStream zip(out);
wxTextOutputStream data(zip);
fstream file1("C:\\test.log", ios::in );
zip.PutNextEntry("C:\\test.log");
char t;
while(file1.good())
{
file1.get(t);
cout << t ;
data << t;
}
file1.close();
}
Cheers,
Kieran