C & C++

C & C++

Made by DeepSource

Loop body is not enclosed in {} CXX-W1243

Anti-pattern
Minor

Loop body not being enclosed in {} can make it confusing and hard to read, hence consider using {} for loop body.

Bad practice

int x = 0;
while (x < 10) x++;

Recommended

int x = 0;
while (x < 10) {
    x++;
}