Search notes:

C: for

Exiting a for loop

A for loop is exited with the break keyword
#include <stdio.h>

int main() {

  int i;

  for (i=1; i<10; i++) {
    printf("i = %d\n", i);

    if (i == 5) {
    //
    // break exits the for loop, thus
    // only the numbers 1 through 5
    // are printed
    //
       break;
    }

  }
}
Github repository about-c, path: /for/break.c

See also

C language

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759398183, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/C-C-plus-plus/C/language/for/index(63): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78