Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //master.cpp
- #include <iostream>
- #include <string>
- #include <string.h>
- #include <stdio.h>
- #include <ctype.h>
- using namespace std;
- // Declarations
- string myString;
- // Functions
- bool IsVowel(char stringElement);
- string RemoveVowels(string inString);
- // Main
- int main()
- {
- cout << "Welcome, enter a string to remove vowels from:" << endl;
- getline (cin,myString);
- myString = RemoveVowels(myString);
- cout << endl << "Your string without vowels: " << myString << endl << endl;
- system("pause");
- }
- // Functions Body
- bool IsVowel(char stringElement)
- {
- if (isupper(stringElement))
- {
- tolower(stringElement);
- }
- if (stringElement == 'a' || stringElement == 'e' || stringElement == 'i' || stringElement == 'o' || stringElement == 'u' || stringElement == 'y')
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- string RemoveVowels(string inString)
- {
- unsigned int i = 0;
- while (i < inString.length())
- {
- if (IsVowel(inString[i]))
- {
- inString.erase(i,1);
- }
- else
- {
- i++;
- }
- }
- return inString;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement