substr throwing out of range, even if par set to 0

Good morning all. Anyway, the code I have is in a class so it too long to past here, so I will have to explain. I am writing a hotel reservation system, as such it has a date header that is responsible for date and time.

The issue is that sometimes when i execute the program a out of range exception is thrown, and other times it is not, even though the same information is being entered to test for consistency. Also the substr always has the first argument set to 0. So unless the string does not exist, which I have already confirmed it does, these errors are illogical.

So are there any suggestions. And is there a way to find out which line my exception is being thrown from.
It's really hard to help someone by only being able to make shots in the dark.

If you can't paste the code here, then could you please upload the relevant parts of it to http://www.pastebin.com or other paste service?

Thank you,
-Albatross
And is there a way to find out which line my exception is being thrown from.
Yes. Use a debugger. Depending on your IDE there will be different ways to use it in conjunction with said IDE.
@Albatross
http://pastebin.com/Lf5uQ4dH

@MiiNiPaa would you be able to tell me how to do that with gdb debugger.
Line 359: string sub=val.substr(val.find(dateDelimeter)+1, (val.length()-(val.find(dateDelimeter)+1)));
If dateDelimeter is the last character in line will lead to exception. Alternatively depending on implementation can lead to exception if dateDelimiter is not found.

Which IDE do you use?
http://www.cplusplus.com/forum/general/112111/


$ g++ -ggdb -Wall -Wextra -Wpedantic main.cpp -o a.out
$ gdb a.out
> run
(Crash)
> backtrace
Topic archived. No new replies allowed.