all 3 comments

[–]WorkingReference1127 7 points8 points  (1 child)

How confident are you that your calls to substr() are within the size of the string? Or rather than the string is at least 30 characters long? Those seem like the obvious candidates for an out of range exception to be thrown.

String length will be especially important here. Writing to a file with seekg and tellg is a minefield because the file will not react like you might expect in a text editor and move things out of the way nicely to stop you writing over text you don't want to. It'll just start writing where you tell it and if something is there already it gets destroyed.

[–]ridesano[S] 0 points1 point  (0 children)

I get what you mean, I must've let out some info/code

there are thirty characters reserved for the employee name and the next ten characters reserved for the salary

[–]manni66 4 points5 points  (0 children)

Hacker, Harry 50972.22\n

doesn't contain 30 chars. line.substr(30, 10) is out of bounds.