Instructions
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.
For example, if str = "There", then after removing all the vowels, str = "Thr".
After removing all the vowels, output the string.
Your program must contain a function to remove all the vowels and a function to determine
whether a character is a vowel.
I see substr takes (position, size)
so I'm assuming there is no way to actually put into substr to take out certain values but will have to write the string a certain way to equal the same
You should be able to do this without pointers. [That was a joke.]
"The program then uses the function substr to remove all the vowels from the string."
Where are you defining this function "substr" that you're calling? Not the clearest instructions, but I assume it's talking about the member function of std::string called "substr", and not your own function. http://www.cplusplus.com/reference/string/string/substr/
I don't actually see how using substr is useful here.
Your program must contain a function to remove all the vowels
I don't understand signatures of the functions you're using. You're not even passing anything into your check_vowels function. To me, the instructions mean that you should write a function that takes in a string, and returns another string with the vowels removed. Or the string should be passed by reference. But either way, you need to pass a string as a parameter. Just like how you pass char ch as a parameter to check_vowels, you need to pass the string into your "remove vowels" function.
The coding you gave me passes the check
but for learning sake i wanna learn how to use the substr if possible.
reading the link above tryen to figure out how to use the substr to pull out the vowels it comes across
Sadly, I can't think of any remotely sensible way to use std::string.substr() to remove all the vowels. Are you sure that you have read your assignment correctly?
BTW do not edit your original post when you make changes. It just confuses people that see the first post and do not realize that you have changed it. It is better to make a new message to show your changes.
After rearranging the instructions:
Instructions
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.
For example, if str = "There", then after removing all the vowels, str = "Thr".
After removing all the vowels, output the string.
Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel.
Here is the confusing part. Does "function substr" mean a function that you write or the member function of the string class called "substr"?
Now that I have reread everything a couple of times I understand better.
The page I pointed you to was to see how "find_first_of" works. Not so much to copy it and try to use it.
Using the return value of "find_first_of" and "myString.substr()" you can create a new string with out the vowels.
I do believe that is the intent of the instructions.
Oh i totally understand Handy andy, i just liked how simple their post was and decided to try and modify it.
As for the edits, it was more editing to read better but not modify the original words to the original post.
my understanding of things works better when its simple and slowly adding in more complicated function.
I also liked mikeStgt post, the \0 worked beautifully and kept the original coding intact and simple. even though we weren't able to get the substr in
still reading over the other post as well
and i want to thank you all for the coding ideas though future reference next to the coding if you can add (//information about the code and why) so i can understand why it has been done
My idea how to abuse substr() for this task was, concatenate the substring before the vowels with the substring after it, skipping this way over the vovel in question. I coded it last nite but did not publish it. (Honestly, it was late and I was too lazy to debug find(), it did not work as I assumed from REXX.)