A
Alexandros
I do something like this:
ifstream file(argv[1]); if(!file) //...
file.read(buffer,BUFFSIZE);
while(!file.eof())
{
for(int i=0; i<BUFFSIZE; i++)
// ...
file.read(buffer,BUFFSIZE);
}
int nlastread=file.gcount();
for(int i=0; i<nlastread; i++)
// ...
And then things like these don't work;
file.seekg(0); // file.tellg() is -1
file.seekg(20) // file.tellg() is still -1
file.close(); file.open(argv[1]) // Can't open: !file is true.
the only way to do it I've found is:
ofstream file2(argv[1]);
but I'm not very keen on that solution.
What do you think?
ifstream file(argv[1]); if(!file) //...
file.read(buffer,BUFFSIZE);
while(!file.eof())
{
for(int i=0; i<BUFFSIZE; i++)
// ...
file.read(buffer,BUFFSIZE);
}
int nlastread=file.gcount();
for(int i=0; i<nlastread; i++)
// ...
And then things like these don't work;
file.seekg(0); // file.tellg() is -1
file.seekg(20) // file.tellg() is still -1
file.close(); file.open(argv[1]) // Can't open: !file is true.
the only way to do it I've found is:
ofstream file2(argv[1]);
but I'm not very keen on that solution.
What do you think?