How to use break and continue

Stop with break

break exits the nearest loop or switch. It is useful when a search succeeds.

for (size_t i = 0; i < count; ++i) {
    if (values[i] == target) {
        found = true;
        break;
    }
}

Skip with continue

continue starts the next loop iteration. In a for loop, the update expression still runs.

for (int n = 1; n <= 10; ++n) {
    if (n % 2 != 0) {
        continue;
    }
    printf("%d\n", n);
}

Exit nested loops carefully

A break affects only the nearest loop. Put nested search logic in a function and return a result when that makes the exit clearer.

Keep cleanup reachable

If a function owns an open file or allocated memory, release it before an early return. A single cleanup section is sometimes clearer than duplicating cleanup.