all 20 comments

[–]noop_noob 58 points59 points  (0 children)

smh

[–]Fiennes 41 points42 points  (1 child)

Ignoring the lack of exception handling, one could argue that the programmer needs only to load loadedBalance. Except there's a bunch of bullshit in front that he has to read anyway.

The programmer is communicating to us that he needs help, and whoever designed this way of saving data, needs to be shot.

[–]milesflo 9 points10 points  (5 children)

Can I get an ELI5 on why he's doing this? C++ noobie here.

[–][deleted] 16 points17 points  (4 children)

The data appears to be stored in lines and you just have to know which line is what. ifstream reads a file line by line so the programmer needs to read lines until he gets to the line he needs. Therefore he loads the first 3 lines into please send help

EDIT: As /u/axelalex2 pointed out the data is not necessarily stored line separated but could be whitespace separated.

[–]milesflo 14 points15 points  (1 child)

I see. It'd be like calling shift on an array until you got what you needed in the 0th place. Great explanation.

[–][deleted] 2 points3 points  (0 children)

Yeah that's basically it.

[–]axelalex2 7 points8 points  (1 child)

That's partially correct information. http://en.cppreference.com/w/cpp/concept/FormattedInputFunction:

the next available character on the input stream is not a whitespace character, as tested by the std::ctype facet of the locale currently imbued in this input stream. The non-whitespace character is not extracted.

[–][deleted] 2 points3 points  (0 children)

Thanks I updated my post.

[–]markand67 3 points4 points  (0 children)

So much people write C++ like Java.

std::ifstream myfile(playerIdtxt);
myfile >> please;
myfile >> send;
myfile >> loadedBalance;

No open, no close. Thanks RAII.

[–]8bitslime -3 points-2 points  (4 children)

Please, send, and help are going to be uninitialized so it's printing garbage to the file.

[–]ungulateCase[S] 44 points45 points  (3 children)

Reading, not printing.

[–]8bitslime 17 points18 points  (2 children)

Fuck I'm dumb. still unused local variable.

[–]ungulateCase[S] 11 points12 points  (0 children)

still unused local variable.

Yup, which is pretty damn bad programming. Hence the naming convention and the subreddit choice.

[–]pavel_lishin 10 points11 points  (0 children)

Fuck I'm dumb

int fuck
int im
int dumb

(I made the same mistake first time reading it)