gpt4 book ai didi

c - 为什么我的变量在编译时报告为 "undeclared identifier"?

转载 作者:行者123 更新时间:2023-11-30 18:40:01 34 4
gpt4 key购买 nike

我有以下代码:

       for(int iY=0;iY<(Height-YRemainder);iY=iY+16);
{
for(int iX=0;iX<(Width-XRemainder);iX=iX+16);
{
if(Operation==BLACKNESS)
{
Operation = WHITENESS;
PatBlt(DeviceContext, iX, iY, 16, 16, Operation);
}
else
{
Operation = BLACKNESS;
PatBlt(DeviceContext, iX, iY, 16, 16, Operation);
}
}
if(Operation == BLACKNESS)
{
Operation = WHITENESS;
PatBlt(DeviceContext, Width-XRemainder,iY,16,16,Operation);
}
else
{
Operation = BLACKNESS;
PatBlt(DeviceContext, Width-XRemainder, iY, 16, 16, Operation);
}


}

编译时,我得到针对 iX 和 iY 的每个 PatBlt 报告的未声明标识符。我是否误解了每个变量的作用范围,或者我错过了什么?

提前致谢

最佳答案

for 语句末尾有分号,可将它们转换为单行语句:

for(int iY=0;iY<(Height-YRemainder);iY=iY+16);

变成

for(int iY=0;iY<(Height-YRemainder);iY=iY+16)

关于c - 为什么我的变量在编译时报告为 "undeclared identifier"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27722263/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com