当我执行下面的代码时,没有输出,可能是什么原因?

When I execute the following code, there is no output, what could be the cause?

这是我的 C 代码。我没有得到任何输出。请帮忙。我也尝试在主函数中添加初始化,然后我也没有得到任何输出。

#include <stdio.h>

int x = 10;
int main()
{
    if (x = 20)
    {
        x = -1;
    }
    else
    {
        printf("x not eqaul to 20\n");
    }
    if (x > 0)
    {
       printf("x not greather than 0\n");
    }
    else
    {
        /* notjing */
    }
    return 0;
}

所以在第一个 if 语句中你写了 if(x=20)。这不是一个条件参数,这是一个数学操作数。

所以x将被设置为20; afterworths 它将被设置为-1。并且不会调用 printf()

如果您想使用 if(x==20)