在使用变量之前,需要在函数之内先声明变量。例如:
#include 
void calculate(){
    int a = 10;
    int b = 5;
    int c = a + b;
    printf("The result is %d", c);
}
int main(){
    calculate();
    return 0;
}
 在上面的例子中,变量a、b、c已经在calculate()函数之内声明了,所以可以在函数中使用这些变量进行运算。如果没有在函数中声明这些变量,就会出现"My variable is not declared in the function. c language"这样的错误提示信息。
                    上一篇:变量没有渲染
                
下一篇:变量没有正确初始化的错误