4 ms·
To the author: the initial for loop is not equivalent to a do/while loop. The condition of the for loop is executed before the loop runs. e.g. the loop body wil
by hermitdev 4y ago
To the author: the initial for loop is not equivalent to a do/while loop. The condition of the for loop is executed before the loop runs. e.g. the loop body will never run if *count == 0.
- codetrotter 4y agoThere’s an if statement around the do while loop on that page, so that the do while loop also will not run if *count == 0. The code snippets for (int i = 0; i < *count; ++i) { str[i] = 0; } and if (*count > 0) { long idx = 0; do { str->__data[idx] = 0; idx += 1; } while (idx <= *count); } Will produce the same changes to the string data given the same count.