我的代码中有错误,未声明的标识符
I have an error in my code, undeclared identifier
尝试编译时显示错误
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;
}
在使用函数之前,您需要先对函数进行原型设计。否则编译器不知道它的存在:
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.
}
相关文章:
- 在顶点着色器中使用 OpenGl 的未声明标识符,我在顶点着色器中绘制三角形时遇到问题
- Google protobuf 时间戳未声明标识符,在 Windows 上具有C++
- 我的函数调用 (C++) 中的未声明标识符
- 具有继承的未声明标识符(运算符 ostream)
- 无法确定 IDE 在 C++ 中说出未声明标识符的原因
- 错误 C2065:'lO':用于声明向量值的未声明标识符?
- 可变参数模板的未声明标识符
- 动态变量上的c++MACRO未声明标识符
- 指向对象的指针的未声明标识符向量
- 简单C++程序上的多个未声明标识符
- C++类"未声明标识符"
- 计算文本文件中的整数数(使用 fin>>x 的未声明标识符)
- 编译器错误 xcode 未声明标识符 C++
- 直接 X 11 纹理 FX 文件错误 X3004 未声明标识符"input"
- GCC 未声明标识符"_asm"
- ios_base类的C++未声明标识符
- 未声明标识符SQL_SS_TABLE
- 使用arrayfire的未声明标识符
- 未声明标识符和标识符未定义是什么意思?如何修复错误
- 在 MacOS 上使用 OpenMPI C++语法时未声明标识符'MPI'