I am writing a string manipulation program, but when I try to use pos to keep track of the location of "tab" in the string that was read in from a file it crashes the whole program when I try to run it. When I step through the program it works for the first time it runs through the nested while loop until the end of the file [while(!fbackup.eof())], but when I get to the second time it runs that while loop it causes an "Unhandled exception at 0x7c812afb" and says "std::out_of_range at location..." I am just following the format that the string examples on this website give. I need this for my final project, any help would be wonderful. Thank you in advance.
Whenever you make an assumption about a condition, add an assert to make sure the condition is actually true.
asserts are a great help finding bugs early.
I can't think of a reason for the position to not be valid. Not only do I know that the position is valid because I wrote the test files, but in earlier testing where I had a couple of errors that made it insert everything to only one of the binary search trees I wasn't getting this error.
Well, if the position isn't valid, then there are no \t in your strings. Use a debugger and make sure that the data you are reading is actually what you think it is.
That's actually part of the assignment, but for now I just wanted to make sure that it worked when there were tabs. But now I'm out of time and I have to go and turn it in incomplete, thanks for the help anyway.