Simple "welcome" function being ignored.

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).

#include <iostream>
#include <string>
#include <limits>

using namespace std;

bool isVowel(char ch);
void removeVowels(string userStr);

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

}

userStr = c;

}
Last edited on
> but it's being ignored
you've never called it.
You need to call the welcome function yourself, the compiler won't do it for you.
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.
Last edited on
Topic archived. No new replies allowed.