![]() |
![]() |
#1 (permalink) |
Crazy
Location: Raleigh, NC
|
[c] invalid lvalue in decrement
The expression I am dealing with is
a += ---b--; That is just a small portion of the statement but my job is to add parenthesis to enforce the implicit c precedence rules. I haven't been able to come up with a way to make this work. I keep getting the compile error invalid lvalue in decrement when I try things such as: a = -(--(b--)); a = -((--b)--); etc... Any ideas why this won't run?
__________________
"Good artists copy, great artists steal." - Pablo Picasso |
![]() |
![]() |
#4 (permalink) | |
Psycho
Location: sc
|
Quote:
a += -(b-2); a += (-(b-1))-1;
__________________
This is what is hardest: to close the open hand because one loves.
Nietzsche |
|
![]() |
![]() |
#8 (permalink) |
<3 TFP
Location: 17TLH2445607250
|
I think CSflim has it right. It's been a while since I've done any work in C. Also, skaven, why is it better for him to get an answer from his prof then from some other coders here at the TFP? In fact, I bet some of us are probably better programmers than the teacher, quadruply so if it's a high school assignment. I've been programming for >10 years in various languages, and I've encountered "teachers" that I've had to correct. I'm sure there are those here who have much more knowledge than me.
__________________
The prospect of achieving a peace agreement with the extremist group of MILF is almost impossible... -- Emmanuel Pinol, Governor of Cotobato My Homepage |
![]() |
![]() |
#9 (permalink) |
Junkie
|
if this is a homework question then the school needs to find a new teacher. Using pre and post increment operators like that is very bad form. The only exception would be if the professor was trying to show that such a statement is bad form. Pre and post increment operators should only be used in simple statements to avoid obscure equations like above. Such an equation is a nightmare for debugging and code maintenance.
|
![]() |
![]() |
#10 (permalink) | |
Junkie
Location: San Francisco
|
Quote:
![]() ![]() |
|
![]() |
Tags |
decrement, invalid, lvalue |
|
|