繁体   English   中英

想知道为什么我收到错误“使用未声明的标识符”

[英]Wondering why I'm getting the error “use of an undeclared identifier”

   // TODO: Calculate number of years until we reach threshold
   { 
    int years;
    while (ending_size>=starting_size)
    starting_size = starting_size + (starting_size/3) - (starting_size/4);
    years++;
    }
            {// TODO: Print number of years
            printf("Years: %i\n", years);
            }
}

当我运行我的代码时,它说“使用未声明的标识符“年”,我认为这可能是由于我格式化代码的方式。谢谢

看起来您在声明年份的代码周围有{ ... } 我认为这是你的问题。 {}限制了它的 scope。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM