What to do (keyword) C ++?

I never knew there was a keyword, do, in C ++!
what is it?

+3
source share
6 answers

This is the loop:

do {
...
} while(someCondition);
+13
source

Good thing it is used with while keyword:

do {
   ...
} while(foo)

Unlike a loop for a do-while loop, it always runs at least once .

Also note that do {} while (0) is a commonly used idiom in the Linux kernel, see this faq for details.

+9
source

. , . ,

do {
/* Code will always be executed at least once */
/* something needed to be done once or more times */
} while ( /* not done /* )

as

while( /* not done */) {
 /* this code may never be executed */
}
+5

while ( ), , do..while, , , , while, .

+1

do do... while. while, , do... while .

+1

do while , () .

while ( );

0

Source: https://habr.com/ru/post/1782119/


All Articles