Sorry about the crappy formatting - it looks fine before I post.
I just want a simple "welcome" message for my program, but it's being ignored. No errors, no issues with the rest of the program (except for warning C4018: '<=': signed/unsigned mismatch in the removeVowel function).
void welcome() //Welcome the user and explain the program
{
cout << "Welcome to my vowel removal program!" << endl;
cout << "This program will take what you enter in below, " <<
"remove the vowels, and then print the result" << endl;
}
int main() //Takes input and calls the removeVowels function to strip the vowels
{
string input = ""; // Holds the user's input in a string for use later
cout << "Enter a word or phrase here: ";
getline(cin, input); // getline allows for spaces in the input
cout << "\nYour word or phrase without vowels is: ";
removeVowels(input); // Calls the removeVowels function on the user input
cin.ignore(numeric_limits<streamsize>::max(), '\n'); // Runs through the whole string, regardless of the length
cout << endl;
return 0;
}
bool isVowel(char ch)
{
switch (ch)
{
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':
return true;
default:
return false;
}
}
void removeVowels(string userStr)
{
string a, b, c;
char ch;
int i;
for (i = 1; i <= userStr.length(); i++)
{
ch = userStr[i - 1];
if (isVowel(ch))
{
a = userStr.substr(0, i - 1);
b = userStr.substr(i + 1, userStr.length() - 1);
c = a;
c += b;
}
else
{
cout << userStr.substr(i - 1, 1); // Prints what is left over after vowels have been removed.
}
Thank you both for the help. Programming is definitely not going to be my chosen path after this class is over.
Is calling it as simple as adding a cout << welcome << endl; to int main()?
EDIT - Finally realized I was overthinking it. For anyone else as bad at this as I am, you would just need to add "welcome();" (or similar) to your main function.