使用C ,我不断获得我似乎无法避免的可变错误的重新定义

Using c++ I keep getting a redefinition of variable error that I cannot seem to avoid

本文关键字:错误 定义 新定义 使用      更新时间:2023-10-16

我想做的代码要做

代码应接受用户的int值,并比较其尺寸。如果u中的值小于或等于l中的值,则将Truth打印到控制台。

错误

IDE(Xcode 9.1)不断给我这个错误

Redefinition of u

如何更正此?

#include <iostream>
using namespace std;
int main() {
    int u, l;
    cout << "Enter value : n";
    cin >> u;
    cout << "Enter next value : n";
    cin >>  l;
    if (u<=l) {
        cout << "Truth";
    }
}

对于代码来说应该没有问题尝试再次创建一个新项目,也许您在某个地方定义了" U"

这个问题是我在代码中有一个全局 u。我删除了它。