Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. After removing all the vowels, outputs the string...
I just need help writing the substr function for the removal of the vowels. Could some one help me or at least point me in the right direction?
There is no any difficulty. First of all you should define a const character array of vowels in the function. Then you simply should copy the original string into another string omiting vowels.
1 2 3 4 5 6 7 8 9 10 11 12
std::string substr( const std::string &s )
{
staticconstchar vowels[] = "...."; // list here all vowels
std::string t;
for ( std::string::size_type i = 0; i < s.size(); i++ )
{
if ( !std::strchr( vowels, s[i] ) ) t += s[i];
}
return ( t );
}
@OP
I'll try to help clean up some of your confusion.
Is it a requirement that you the function std::string::substr? or is substr a function that you create?
Vlad from moscow was on the right track to providing you an answer, however, it would be understandable if, as a beginner, being given all that code is overwhelming.
Have you gave an attempt at writing code for this problem yet, NOFYE?