错误:需要作为左操作数的赋值(C) [英] error: lvalue required as left operand of assignment (C)

查看:1161
本文介绍了错误:需要作为左操作数的赋值(C)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到这个问题的许多不同的答案,看了很多人,但我找不到我的问题的答案。

I see many different answers to this question and have looked at many of them yet I cannot find the answer to my problem.

p>

The error im getting is

bitarray.c:27:19: error: lvalue required as left operand of assignment

(newArr << i) ^= 1;

任何想法?
感谢

Any ideas? Thanks

推荐答案

您正在尝试为操作的结果分配另一个结果。尝试以下正确的方法:

You are trying to assign to a result from an operation another result. Try the following right way to do it:

newArr = (newArr << i) ^ 1;

这个想法是你必须有一个有效的lv值和< ;不是有效的。你需要一个变量,如newArr。 SO的以下答案解释了与这种情况相关的许多术语:

The idea is that you have to have a valid lvvalue and the temporary result of the "<<" is not a valid one. You need a variable like newArr. The following answer on SO explains many terms related to this situation:

什么是右值,左值,x值,glvalues和prvalues?

希望我问题!

这篇关于错误:需要作为左操作数的赋值(C)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆