为什么只有前y和x未声明?

时间:2015-04-13 05:04:57

标签: c++

error C2143: syntax error : missing ';' before ')'

error C2143: syntax error : missing ';' before '/'

error C2065: 'y' : undeclared identifier

error C2065: 'y' : undeclared identifier

error C2143: syntax error : missing ';' before ')'

error C2143: syntax error : missing ';' before '/'

error C2065: 'x' : undeclared identifier

error C2065: 'x' : undeclared identifier

error C2065: 'x' : undeclared identifier

error C2065: 'y' : undeclared identifier

error C2065: 'x' : undeclared identifier

error C2065: 'y' : undeclared identifier

以下是代码:

for (int y = Scan->RcWindow.bottom - Scan->RcWindow.top) / 4;
        y < ((Scan->RcWindow.bottom - Scan->RcWindow.top) - (Scan->RcWindow.bottom - Scan->RcWindow.top)) / 3.5;
    y++;

for (int x = Scan->RcWindow.right - Scan->RcWindow.left) / 4;
        x < ((Scan->RcWindow.right - Scan->RcWindow.left) - (Scan->RcWindow.right - Scan->RcWindow.right)) / 4;
    x++;

我的意思是扫描窗口而忽略侧面,就像使窗口较小,只扫描中间部分(光标周围的部分)。 我不是一个初学者。 感谢您将其编辑为代码格式。

3 个答案:

答案 0 :(得分:2)

您有语法错误,可能是因为缺少括号。目前尚不清楚你的意图,但显然这不是正确的:

for (int y = Scan->RcWindow.bottom - Scan->RcWindow.top) / 4;
    ^                                                  ^

如果将右括号与其对应的左括号匹配,则/ 4;将挂起。也许你想要:

for (int y = (Scan->RcWindow.bottom - Scan->RcWindow.top) / 4;
    y < ((Scan->RcWindow.bottom - Scan->RcWindow.top) -
         (Scan->RcWindow.bottom - Scan->RcWindow.top)) / 3.5;
    y++);

答案 1 :(得分:1)

看看这部分:

for (int y = Scan->RcWindow.bottom - Scan->RcWindow.top) / 4;

                                                       ^ // THIS

您正在关闭for并且您将for循环除以4,这是没有意义的。

答案 2 :(得分:0)

两个for循环语句似乎不完整。也许它应该是

for (int y = Scan->RcWindow.bottom - Scan->RcWindow.top) / 4;
        y < ((Scan->RcWindow.bottom - Scan->RcWindow.top) - (Scan->RcWindow.bottom - Scan->RcWindow.top)) / 3.5;
        y++);

for (int x = Scan->RcWindow.right - Scan->RcWindow.left) / 4;
        x < ((Scan->RcWindow.right - Scan->RcWindow.left) - (Scan->RcWindow.right - Scan->RcWindow.right)) / 4;
        x++);