I started playing with c++ in Arduino a I am enjoying it a lot!
I've read plenty of foruns and literature, but I really can't figure this one out.
I have two equal objects, but when submitted to the same test, they present different outputs.
On the left you have the code of the function, and on the right, the output. I have placed a few prints to debug it...
But, why oh why the function does not enter in the loop!??!?!?!?
I started playing with c++ in Arduino a I am enjoying it a lot!
I've read plenty of foruns and literature, but I really can't figure this one out.
I have two equal objects, but when submitted to the same test, they present different outputs.
On the left you have the code of the function, and on the right, the output. I have placed a few prints to debug it...
But, why oh why the function does not enter in the loop!??!?!?!?
Thanks
Describe the problem accurately, and post your code between code tags. ( </> in the reply window. )
As Bob has just pointed out as well.
Place your output in code tags too.
N.B. There's nothing on either the left or right at the moment.
Here, i = zero (altho you haven't initialized it),
so first + i * size_entry is the same as first.
for (i=(int) first; (int)(first+i*size_entry) < (int)first_available; i++) {
Here, when you evaluate the condition, you have already assigned a new value to i: first.
So now, first + i * size_entry is potentially greater than first_available,
and then the condition would never be true.