开发者

error: lvalue required as left operand of assignment

开发者 https://www.devze.com 2023-04-12 14:56 出处:网络
I\'m trying to do some calculation program using C what am I getting error is error: lvalue required as left operand of assignment

I'm trying to do some calculation program using C what am I getting error is

error: lvalue required as left operand of assignment

This error cause from define a value on the header and then I assign using = in the main body.

If I put that value which it is in the header instead put them in the int or double then it will be 开发者_JAVA技巧fine, but I don't want them to be there.

please tell me if needed more information about what I'm trying to say.

Thanks


here is what I put on the define #define price 50

and in the body where I'm getting error price = price * 2 + total


You can't assign to a define! After the preprocessor is done, to the compiler the code looks like this:

50 = 50 * 2 + total;


The problem is that price is being replaced with the text 50. You can't have

50 = ...

in C. Can't do it.

0

精彩评论

暂无评论...
验证码 换一张
取 消