{"id":2499,"date":"2025-07-17T09:22:33","date_gmt":"2025-07-17T08:22:33","guid":{"rendered":"https:\/\/workboot.fr\/ciela\/?page_id=2499"},"modified":"2025-07-17T09:27:55","modified_gmt":"2025-07-17T08:27:55","slug":"les-structures-de-controle","status":"publish","type":"page","link":"https:\/\/workboot.fr\/ciela\/les-structures-de-controle\/","title":{"rendered":"Les structures de contr\u00f4le"},"content":{"rendered":"\n<nav aria-label=\"Table des mati\u00e8res\" class=\"wp-block-table-of-contents\"><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-de-controle\/#1-for-boucle-pour\"> 1. for \u2014 boucle pour<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-de-controle\/#2-while-boucle-tant-que\"> 2. while \u2014 boucle tant que<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-de-controle\/#3-do-while-boucle-faire-tant-que\"> 3. do &#8230; while \u2014 boucle faire tant que<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-de-controle\/#break-interruption-d-une-boucle-ou-d-un-switch\">\ud83d\udd39 break \u2014 interruption d&rsquo;une boucle ou d&rsquo;un switch<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-de-controle\/#goto-saut-inconditionnel\">\ud83d\udd38 goto \u2014 saut inconditionnel<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-de-controle\/#pourquoi-goto-n-est-pas-structure\">\ud83d\udeab Pourquoi goto n\u2019est pas structur\u00e9<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-de-controle\/#pourquoi-break-est-mieux-structure\">\u2705 Pourquoi break est mieux structur\u00e9<\/a><\/li><\/ol><\/li><\/ol><\/li><\/ol><\/nav>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"1-for-boucle-pour\"> 1. <code>for<\/code> \u2014 boucle <strong>pour<\/strong><\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Utilis\u00e9e quand on sait combien de fois on veut r\u00e9p\u00e9ter une action.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for (int i = 0; i &lt; 10; i++) {\n    printf(\"%d\\n\", i);\n}<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"2-while-boucle-tant-que\"> 2. <code>while<\/code> \u2014 boucle <strong>tant que<\/strong><\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Utilis\u00e9e quand on ne conna\u00eet pas d&rsquo;avance le nombre d&rsquo;it\u00e9rations.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">int i = 0;<br>do {<br>    printf(\"%d\\n\", i);<br>    i++;<br>} while (i &lt; 10);<br><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"3-do-while-boucle-faire-tant-que\"> 3. <code>do ... while<\/code> \u2014 boucle <strong>faire tant que<\/strong><\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Semblable \u00e0 <code>while<\/code>, mais le bloc s&rsquo;ex\u00e9cute au <strong>moins une fois<\/strong>, m\u00eame si la condition est fausse au d\u00e9part.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int i = 0;<br>do {<br>printf(\"%d\\n\", i);<br>i++;<br>} while (i &lt; 10);<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"break-interruption-d-une-boucle-ou-d-un-switch\">\ud83d\udd39 <code>break<\/code> \u2014 <em>interruption d&rsquo;une boucle ou d&rsquo;un <code>switch<\/code><\/em><\/h1>\n\n\n\n<p class=\"wp-block-paragraph\"><code>break<\/code> est utilis\u00e9 pour <strong>sortir imm\u00e9diatement<\/strong> d\u2019une boucle (<code>for<\/code>, <code>while<\/code>, <code>do...while<\/code>) ou d\u2019un <code>switch<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for (int i = 0; i &lt; 10; i++) {<br>if (i == 5) {<br>break; \/\/ Sort de la boucle quand i vaut 5<br>}<br>printf(\"%d\\n\", i);<br>}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\u27a1\ufe0f R\u00e9sultat : <code>0 1 2 3 4<\/code><\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"goto-saut-inconditionnel\">\ud83d\udd38 <code>goto<\/code> \u2014 <em>saut inconditionnel<\/em><\/h1>\n\n\n\n<p class=\"wp-block-paragraph\"><code>goto<\/code> permet de <strong>sauter \u00e0 un label<\/strong> d\u00e9fini dans le code. C&rsquo;est tr\u00e8s puissant, mais <strong>\u00e0 utiliser avec prudence<\/strong>, car cela peut rendre le code difficile \u00e0 lire.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">label ou \u00e9tiquette en dans la langue de Moli\u00e8re.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n\nint main() {\n    int x = 0;\n\n    if (x == 0)\n        goto <mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\">erreur<\/mark>;\n\n    printf(\"Tout va bien.\\n\");\n    return 0; \/* EXIT_SUCCESS *\/\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\">erreur<\/mark>:\n    printf(\"Une erreur est survenue.\\n\");\n    return 1; \/* EXIT_FAILURE *\/\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"pourquoi-goto-n-est-pas-structure\">\ud83d\udeab Pourquoi <code>goto<\/code> n\u2019est <strong>pas structur\u00e9<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>goto<\/code> permet de sauter <strong>n\u2019importe o\u00f9<\/strong> dans le code (avant ou apr\u00e8s), ce qui <strong>brise la logique lin\u00e9aire<\/strong> du programme.<\/li>\n\n\n\n<li>Cela cr\u00e9e ce qu\u2019on appelle du <strong>\u201ccode spaghetti\u201d<\/strong>, tr\u00e8s difficile \u00e0 lire, comprendre, ou corriger.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"pourquoi-break-est-mieux-structure\">\u2705 Pourquoi <code>break<\/code> est <strong>mieux structur\u00e9<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Il n\u2019envoie pas l\u2019ex\u00e9cution n\u2019importe o\u00f9, <strong>il respecte la structure du langage<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">M\u00eame si <code>break<\/code> interrompt une boucle, <strong>il reste dans un bloc bien d\u00e9fini<\/strong> (<code>for<\/code>, <code>while<\/code>, <code>switch<\/code>).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. for \u2014 boucle pour Utilis\u00e9e quand on sait combien de fois on veut r\u00e9p\u00e9ter une action. 2. while \u2014 boucle tant que Utilis\u00e9e quand on ne conna\u00eet pas d&rsquo;avance [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","_uag_custom_page_level_css":"","footnotes":""},"class_list":["post-2499","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Les structures de contr\u00f4le - workboot<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-de-controle\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Les structures de contr\u00f4le - workboot\" \/>\n<meta property=\"og:description\" content=\"1. for \u2014 boucle pour Utilis\u00e9e quand on sait combien de fois on veut r\u00e9p\u00e9ter une action. 2. while \u2014 boucle tant que Utilis\u00e9e quand on ne conna\u00eet pas d&rsquo;avance [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/workboot.fr\/ciela\/les-structures-de-controle\/\" \/>\n<meta property=\"og:site_name\" content=\"workboot\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-17T08:27:55+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/les-structures-de-controle\\\/\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/les-structures-de-controle\\\/\",\"name\":\"Les structures de contr\u00f4le - workboot\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#website\"},\"datePublished\":\"2025-07-17T08:22:33+00:00\",\"dateModified\":\"2025-07-17T08:27:55+00:00\",\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/workboot.fr\\\/ciela\\\/les-structures-de-controle\\\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#website\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/\",\"name\":\"workboot\",\"description\":\"Open Source, Open Minds \",\"publisher\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#organization\",\"name\":\"workboot\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/logo_ciel-dorian-1.png\",\"contentUrl\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/logo_ciel-dorian-1.png\",\"width\":1024,\"height\":950,\"caption\":\"workboot\"},\"image\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Les structures de contr\u00f4le - workboot","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/workboot.fr\/ciela\/les-structures-de-controle\/","og_locale":"fr_FR","og_type":"article","og_title":"Les structures de contr\u00f4le - workboot","og_description":"1. for \u2014 boucle pour Utilis\u00e9e quand on sait combien de fois on veut r\u00e9p\u00e9ter une action. 2. while \u2014 boucle tant que Utilis\u00e9e quand on ne conna\u00eet pas d&rsquo;avance [&hellip;]","og_url":"https:\/\/workboot.fr\/ciela\/les-structures-de-controle\/","og_site_name":"workboot","article_modified_time":"2025-07-17T08:27:55+00:00","twitter_misc":{"Dur\u00e9e de lecture estim\u00e9e":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/workboot.fr\/ciela\/les-structures-de-controle\/","url":"https:\/\/workboot.fr\/ciela\/les-structures-de-controle\/","name":"Les structures de contr\u00f4le - workboot","isPartOf":{"@id":"https:\/\/workboot.fr\/ciela\/#website"},"datePublished":"2025-07-17T08:22:33+00:00","dateModified":"2025-07-17T08:27:55+00:00","inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/workboot.fr\/ciela\/les-structures-de-controle\/"]}]},{"@type":"WebSite","@id":"https:\/\/workboot.fr\/ciela\/#website","url":"https:\/\/workboot.fr\/ciela\/","name":"workboot","description":"Open Source, Open Minds ","publisher":{"@id":"https:\/\/workboot.fr\/ciela\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/workboot.fr\/ciela\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Organization","@id":"https:\/\/workboot.fr\/ciela\/#organization","name":"workboot","url":"https:\/\/workboot.fr\/ciela\/","logo":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/workboot.fr\/ciela\/#\/schema\/logo\/image\/","url":"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2025\/05\/logo_ciel-dorian-1.png","contentUrl":"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2025\/05\/logo_ciel-dorian-1.png","width":1024,"height":950,"caption":"workboot"},"image":{"@id":"https:\/\/workboot.fr\/ciela\/#\/schema\/logo\/image\/"}}]}},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"admin","author_link":"https:\/\/workboot.fr\/ciela\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":"1. for \u2014 boucle pour Utilis\u00e9e quand on sait combien de fois on veut r\u00e9p\u00e9ter une action. 2. while \u2014 boucle tant que Utilis\u00e9e quand on ne conna\u00eet pas d&rsquo;avance [&hellip;]","_links":{"self":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/2499","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/comments?post=2499"}],"version-history":[{"count":6,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/2499\/revisions"}],"predecessor-version":[{"id":2508,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/2499\/revisions\/2508"}],"wp:attachment":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/media?parent=2499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}