当我已经声明的变量时未声明的标识符错误 [英] undeclared identifier error occurs when I already have declared the variable
本文介绍了当我已经声明的变量时未声明的标识符错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从后续code未声明的标识符错误,但我已经明确宣布在这两种情况下变长。我做了什么错了?
INT startWordLenRec(char中[]){
如果(isLetter(S)== FALSE){
INT长度= 0;
}
否则,如果{
INT长度= 1 + startWordLenRec(S + 1);
}
返回的长度;
}
解决方案
一个声明是本地声明它的范围。所以,如果你把它声明里面 {}
,它不能闭幕后使用}
。
INT startWordLenRec(char中[]){
INT长;
如果(isLetter(S)== FALSE){
长度= 0;
}
否则,如果{
长度= 1 + startWordLenRec(S + 1);
}
返回的长度;
}
当然,你也可以在 0的回报。
直接,没有一个单独的变量
I got an undeclared identifier error from the follow code, but i have clearly declared the variable "length" in both cases. what did I do wrong?
int startWordLenRec(char s[]) {
if (isLetter(s) == false){
int length = 0;
}
else if{
int length = 1 + startWordLenRec(s+1);
}
return length;
}
解决方案
A declaration is local to the scope you declare it in. So if you declare it inside {}
, it cannot be used after the closing }
.
int startWordLenRec(char s[]) {
int length;
if (isLetter(s) == false){
length = 0;
}
else if{
length = 1 + startWordLenRec(s+1);
}
return length;
}
Of course, you can also return 0;
directly, without a separate variable.
这篇关于当我已经声明的变量时未声明的标识符错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文