954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

application requested runtime to terminate in a special way

this worked a few times and now its not :( anny help would be greatly appretiated

#include <iostream>
#include <string>

using namespace std;

string vowels(string str)
{
    string vow = "aeiouAEIOU";
    for(size_t i = 0; i <= str.length()+1; i++)
    {
        str.erase((str.find_first_of(vow)),1);
    }
    return str;
}

int main()
{
    string str;
    cout << "Enter a string of charecters." << endl;
    cin >> str;

    vowels(str);

    return 0;
}
bmanzana
Newbie Poster
13 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

http://www.cplusplus.com/reference/string/string/erase/

pos Position within the string of the first character to be erased. If the position passed is past the end of the string, an out_of_range exception is thrown.

I see no checking for this condition and I see no catching of any exceptions, so if this is in fact occurring, it would certainly "terminate in a special way". Confirm that this doesn't happen or make sure you prevent and / or handle it.

VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
 

some times all you need is a fresh prespective thanx for that i should have seen it along time ago

bmanzana
Newbie Poster
13 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You