Name: Anonymous 2007-04-24 9:38 ID:sLkIt66S
let's say i have a couple of functions
void f1(fstream& file, string filename);
void f2(const string data, int& start, int& end, fstream& file);
when i run f1 i get the following output:
2 (wrong)
80 (right)
2 (wrong)
f1(fstream& file, string data)
{
int start, end;
file.seekg(ios::end);
cout << file.tellg() << endl;
f2(data, start, end, file);
file.clear();
file.seekg(ios::end);
cout << file.tellg() << endl;
}
f2(sting data, int start, int end, fstream& file)
{
file.clear();
file.seekg(0, ios::end);
int FileSize = file.tellg();
cout << FileSize << endl;
}
wtf?
shouldn't it produce:
80
80
80
void f1(fstream& file, string filename);
void f2(const string data, int& start, int& end, fstream& file);
when i run f1 i get the following output:
2 (wrong)
80 (right)
2 (wrong)
f1(fstream& file, string data)
{
int start, end;
file.seekg(ios::end);
cout << file.tellg() << endl;
f2(data, start, end, file);
file.clear();
file.seekg(ios::end);
cout << file.tellg() << endl;
}
f2(sting data, int start, int end, fstream& file)
{
file.clear();
file.seekg(0, ios::end);
int FileSize = file.tellg();
cout << FileSize << endl;
}
wtf?
shouldn't it produce:
80
80
80