Somebody help me ?? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Respostas
+ 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