Reputation: 1
When trying to compile it says error
error: use of undeclared identifier 'isVowel'; did you mean 'islower'?
#include <iostream>
#include <cstring>
using namespace std;
int main() {
char word[50];
int num = 0;
cout << "Enter word: ";
cin.getline(word,50);
for(int i=0; word[i]; ++i){
if(isVowel(word[i]))
++num;
}
cout<<"The total number of vowels are "<<num<<endl;
}
bool isVowel(char c){
if(c=='a' || c=='A')
return true;
else if(c=='e' || c=='E')
return true;
else if(c=='i' || c=='I')
return true;
else if(c=='o' || c=='O')
return true;
else if(c=='u' || c=='U')
return true;
return false;
}
Upvotes: 0
Views: 834
Reputation:
You need to prototype your function before you use it. Otherwise the compiler doesn't know it exists:
bool isVowel(char c); // A prototype of the function you will later call
int main () {
//... Whatever code you're doing....
}
bool isVowel(char c) {
// Actually implement it here.
}
Upvotes: 1