K
Kat
Ok my problem with this program is that currently it isn't overwriting
a dummy TXT file I have set up to test the program. At one point it
did however so I know it should work but now, for some reason, it
won't. I'm using Visual C++ 6.0(yes I know, my school is upgrading
next year) and this program compiles and runs without error(minus the
fact that it doesn't work).
Here's the code
//Begin Code\\
const char zeroa = '0';
const char *zero = &zeroa;
const int MAXCHARS = 81;
char fileloc[MAXCHARS];
cout << "File name(including extension):";
cin.getline(fileloc,MAXCHARS,'\n');
// Open the file in binary mode for read access
ifstream infile (fileloc,ifstream::binary);
// Get the size of the file and close it
long size;
infile.seekg(0,ifstream::end);
size = infile.tellg();
infile.seekg(0);
infile.close();
// Open the file for write access
ofstream outfile (fileloc,ofstream::binary);
// Overwrite the file with numbers
int inte;
for(inte = 0; inte < size; inte++)
{
outfile.write (zero,size);
}
inte = 0;
//End Code\\
Thanks
a dummy TXT file I have set up to test the program. At one point it
did however so I know it should work but now, for some reason, it
won't. I'm using Visual C++ 6.0(yes I know, my school is upgrading
next year) and this program compiles and runs without error(minus the
fact that it doesn't work).
Here's the code
//Begin Code\\
const char zeroa = '0';
const char *zero = &zeroa;
const int MAXCHARS = 81;
char fileloc[MAXCHARS];
cout << "File name(including extension):";
cin.getline(fileloc,MAXCHARS,'\n');
// Open the file in binary mode for read access
ifstream infile (fileloc,ifstream::binary);
// Get the size of the file and close it
long size;
infile.seekg(0,ifstream::end);
size = infile.tellg();
infile.seekg(0);
infile.close();
// Open the file for write access
ofstream outfile (fileloc,ofstream::binary);
// Overwrite the file with numbers
int inte;
for(inte = 0; inte < size; inte++)
{
outfile.write (zero,size);
}
inte = 0;
//End Code\\
Thanks