Why ++++i works and i++++ does not work?
-
Hi all. I'm having this problem and really not getting, what is happening behind the hood. Plzz help me out in this regard. This is basic C concept.
void main ()
{
int i = 0;
++++i; //WORKS
i++++; //DOESN'T WORK
}In the above code,
++++i (Pre-Increment)
works buti++++ (Post-Increment)
doesn't work. What could be the reason? Plzz explain in detail. Any Help is appreciated. -
Hi all. I'm having this problem and really not getting, what is happening behind the hood. Plzz help me out in this regard. This is basic C concept.
void main ()
{
int i = 0;
++++i; //WORKS
i++++; //DOESN'T WORK
}In the above code,
++++i (Pre-Increment)
works buti++++ (Post-Increment)
doesn't work. What could be the reason? Plzz explain in detail. Any Help is appreciated.Because left to righ operator associativity. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
Hi all. I'm having this problem and really not getting, what is happening behind the hood. Plzz help me out in this regard. This is basic C concept.
void main ()
{
int i = 0;
++++i; //WORKS
i++++; //DOESN'T WORK
}In the above code,
++++i (Pre-Increment)
works buti++++ (Post-Increment)
doesn't work. What could be the reason? Plzz explain in detail. Any Help is appreciated. -
Hi all. I'm having this problem and really not getting, what is happening behind the hood. Plzz help me out in this regard. This is basic C concept.
void main ()
{
int i = 0;
++++i; //WORKS
i++++; //DOESN'T WORK
}In the above code,
++++i (Pre-Increment)
works buti++++ (Post-Increment)
doesn't work. What could be the reason? Plzz explain in detail. Any Help is appreciated.Don Box wrote:
i++++; //DOESN'T WORK
The second pair of "++" needs an l-value to operator on, which "i++" is not.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Hi all. I'm having this problem and really not getting, what is happening behind the hood. Plzz help me out in this regard. This is basic C concept.
void main ()
{
int i = 0;
++++i; //WORKS
i++++; //DOESN'T WORK
}In the above code,
++++i (Pre-Increment)
works buti++++ (Post-Increment)
doesn't work. What could be the reason? Plzz explain in detail. Any Help is appreciated.#include int main() { int i = 0; while(i<5) { std::cout << i; i++; } /* while(i<5) { std::cout << i; ++i; } */ std::cout << std::endl; std::cin >> i; return 0; }