Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

wtf? - fstream

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

Name: Anonymous 2007-04-24 9:48 ID:Heaven

failstream

Name: Anonymous 2007-04-24 10:39 ID:Heaven

PROTIP: ios::end == 2

Name: Anonymous 2007-04-24 10:57 ID:ExaVpbkz

iLold

Name: Anonymous 2007-04-24 11:05 ID:Heaven

PROTIP: >>2

Name: Anonymous 2007-04-24 20:45 ID:pOzL7/VZ

file.seekg(ios::end);
file.seekg(0, ios::end);

Name: Anonymous 2007-04-24 22:07 ID:Heaven

thanks guys

Name: Anonymous 2009-02-25 6:50

Is the best programming   language in the   most simple cases?

Name: Anonymous 2009-06-11 12:54

stdio

Name: PANTSU MEME FAN 2009-06-11 13:00

>>9
Expert Thread Bumper

Name: Anonymous 2009-06-12 4:31

>>5
PROTIP: RTFM

Name: Anonymous 2009-06-12 5:08

>>10,11 same person and a moron

Name: Anonymous 2009-08-03 11:37

>>12
num denom  abs( denom;  ); denom; whole num /  num the boost FUCK felt FUCK loeb f Writing Kusaba L_ft; FUCK “I am (~~~~) for AI  =_  |__________)________)-FFFUUUURRR   (~~~~)    show for next increase shure of sig show |_ - utf8 replace replace

Name: ​​​​​​​​​​ 2010-10-23 13:17

Name: Anonymous 2010-12-09 7:07

Name: Anonymous 2011-02-03 0:21

Name: Sgt.Kabu뫿釖kimanᯥ 2012-05-29 0:43

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List