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;
}

Recommended Answers

All 2 Replies

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.