Re: Writing to files

Tech-Archive recommends: Speed Up your PC by fixing your registry



Ok here's a code snippet. The program compiles and works fine. I
guess that's because I'm using Visual C++ 6.0(I know, it's my school's
fault, but they're upgrading next year).

//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\\

.