This code is supposed to take a word that you enter and print back out in reverse so for example if you enter in "Mississippi" it prints out "ippississiM", also it prompts the user for a word to locate within the word they enter before. So if the user wants to locate "issi" it prints out that it was found, and if they enter something that doesnt exist in the word it supposed to print out was not found. This is where my problem is. when i try to enter a word that isnt in the word i get
terminate called after throwing an instance of 'std::out_of_range'
i dont know what exactly is going wrong with my code. any help would be appreciated.
int j = s.length();
wrd = word;
if (wrd.length() < 0) // I don't think that a size_t is ever < 0
first = wrd.substr(0, j);
second = wrd.substr(1, wrd.length()); // If pos is greater than the string length, it throws out_of_range.