不确定如何修复 "lvalue required" 错误

Unsure how to fix "lvalue required" error

#include<stdio.h> 
main()
{
int x,n,r;
scanf("%d" , & x);
    for (n=2;n<(x/2);n++)
    {
            (x%n=r);              //error is here
            (r=0) ? (print("%d\n is a factor")):(print("%d\n is not a factor"));    
    }

}

不知道为什么我会收到 "lvalue required as left operand of assignment" 错误。 任何帮助将不胜感激。

您试图将 r 分配给 x%n,但这是无效的。你可能想要

r=x%n;

另外,替换

(r=0) ? (print("%d\n is a factor")):(print("%d\n is not a factor"));

(r==0) ? (printf("%d\n is a factor",x)):(printf("%d\n is not a factor",x)); 

=是赋值运算符,不是比较运算符(==)。