Our second block code scheme (Table 10.2) has d min =3. This code can detect up to two errors. Again, we see that when any of the valid codewords is sent, two errors create acodddeword whi hhich isnot inthetablble of valid codddewords. The receiver cannot be fooled. However, some combinations of three errors change a.
I have this following code:
![Cannot Cannot](/uploads/1/2/5/6/125632408/628805674.png)
But it gives out an error saying:
Error: expression must be a modifiable value
on that 'if' line. I am not trying to modify 'match' or 'k' value here, but why this error? if I only write it like:
it is ok. Could someone explain it to me?
E_learnerE_learner
4 Answers
The assignment operator has lower precedence than
&&
, so your condition is equivalent to:But the left-hand side of this is an rvalue, namely the boolean resulting from the evaluation of the subexpression
match 0 && k
, so you cannot assign to it.By contrast, comparison has higher precedence, so
match 0 && k m
is equivalent to:Kerrek SBKerrek SB
In C, you will also experience the same error if you declare a:
and than try to assign a value without specifying an index position:
By doing:
You're specifying the accessible/modifiable address previously declared.
AlanAlan
You test
Maybe it is what you want to do, in this case, write
k = M
instead of k M
.Maybe it is what you want to do, in this case, write
if (match 0 && (k = M))
tomahhtomahh
Remember that a single
=
is always an assignment in C or C++. Your test should be
if ( match 0 && k M )
you made a typo on the k M
test.If you really mean
k=M
(i.e. a side-effecting assignment inside a test) you should for readability reasons code if (match 0 && (k=m) != 0)
but most coding rules advise not writing that.BTW, your mistake suggests to ask for all warnings (e.g.
-Wall
option to g++
), and to upgrade to recent compilers. The next GCC 4.8 will give you:and Clang 3.1 also tells you
ederman.cc:9:30: error: expression is not assignable
So use recent versions of free compilers and enable all the warnings when using them.
Basile StarynkevitchBasile Starynkevitch