Re: Writing to files
- From: "Kat" <Rem.Intellegare@xxxxxxxxx>
- Date: 23 May 2006 09:44:27 -0700
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\\
.
- Follow-Ups:
- Re: Writing to files
- From: Tamas Demjen
- Re: Writing to files
- From: Kat
- Re: Writing to files
- References:
- Writing to files
- From: Kat
- Re: Writing to files
- From: Jim Langston
- Writing to files
- Prev by Date: Re: Read memory
- Next by Date: Re: Writing to files
- Previous by thread: Re: Writing to files
- Next by thread: Re: Writing to files
- Index(es):