+ 11

Somebody help me ??

Assuming buf is a valid pointer, what is the problem in the code below? What would be an alternate way of implementing this that would avoid the problem? size_t sz = buf->size(); while ( --sz >= 0 ) { /* do something */ }

2nd Apr 2018, 10:41 AM
Hope
Hope - avatar
2 Respuestas
+ 4
I assume buf is an object with a method called size. You don't need to specify the >=0 in the while condition. It get's executed until the whole statement is <=0 Here: https://code.sololearn.com/cNM5ByDCTfXD/?ref=app If that wasn't the question let me know.
2nd Apr 2018, 11:24 AM
Alex
Alex - avatar
+ 9
thanks
4th Apr 2018, 12:01 PM
Hope
Hope - avatar