{"id":2529,"date":"2025-07-17T14:04:33","date_gmt":"2025-07-17T13:04:33","guid":{"rendered":"https:\/\/workboot.fr\/ciela\/?page_id=2529"},"modified":"2025-07-17T14:11:24","modified_gmt":"2025-07-17T13:11:24","slug":"les-structures-en-langage-c","status":"publish","type":"page","link":"https:\/\/workboot.fr\/ciela\/les-structures-en-langage-c\/","title":{"rendered":"Les structures en langage C"},"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-en-langage-c\/#1-qu-est-ce-qu-une-structure\">1. Qu\u2019est-ce qu\u2019une structure ?<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-en-langage-c\/#2-declaration-d-une-structure\">2. D\u00e9claration d\u2019une structure<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-en-langage-c\/#syntaxe-generale\">Syntaxe g\u00e9n\u00e9rale :<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-en-langage-c\/#exemple-un-point-2d\">Exemple : un point 2D<\/a><\/li><\/ol><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-en-langage-c\/#4-alias-avec-typedef-optionnel-mais-pratique\">4. Alias avec typedef (optionnel mais pratique)<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-en-langage-c\/#exemple-final-nombre-complexe\">Exemple final : nombre complexe<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-en-langage-c\/#exemple-complet-avec-addition-de-complexes\">Exemple complet avec addition de complexes<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-en-langage-c\/#resume\">R\u00e9sum\u00e9<\/a><\/li><\/ol><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-en-langage-c\/#encore-un-exemple-la-multiplication-de-nombres-complexes\">Encore un exemple , la multiplication de nombres complexes <\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-en-langage-c\/#objectif\">Objectif :<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-en-langage-c\/#rappel-mathematique\">\ud83e\udde0 Rappel math\u00e9matique<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/les-structures-en-langage-c\/#code-complet-avec-multiplication\">Code complet avec multiplication :<\/a><\/li><\/ol><\/li><\/ol><\/nav>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"1-qu-est-ce-qu-une-structure\">1. Qu\u2019est-ce qu\u2019une <code>structure<\/code> ?<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">En C, une <strong>structure<\/strong> (<code>struct<\/code>) est un <strong>type de donn\u00e9es<\/strong> qui permet de <strong>regrouper plusieurs variables<\/strong> (de types diff\u00e9rents ou identiques) <strong>sous un m\u00eame nom<\/strong>.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Id\u00e9al pour repr\u00e9senter des objets r\u00e9els : un point, un \u00e9tudiant, un complexe, etc.<\/p>\n<\/blockquote>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"2-declaration-d-une-structure\">2. D\u00e9claration d\u2019une structure<\/h1>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"syntaxe-generale\">Syntaxe g\u00e9n\u00e9rale :<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>struct NomStructure {\n    type1 membre1;\n    type2 membre2;\n    \/\/ ...\n};<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"exemple-un-point-2d\">Exemple : un point 2D<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>struct Point {\n    float x;\n    float y;\n};<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"utilisation-d-une-structure\">Utilisation d\u2019une structure<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"a-declarer-une-variable-de-type-struct\">a. D\u00e9clarer une variable de type <code>struct<\/code><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>struct Point p1;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"b-acceder-aux-membres\">b. Acc\u00e9der aux membres<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">p1.x = 3.5;<br>p1.y = 2.0;<br><br>printf(\"x = %.1f, y = %.1f\\n\", p1.x, p1.y);<\/pre>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"4-alias-avec-typedef-optionnel-mais-pratique\">4. Alias avec <code>typedef<\/code> (optionnel mais pratique)<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>typedef struct {\n    float x;\n    float y;\n} Point;\n\nPoint p1;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u27a1\ufe0f Plus besoin d\u2019\u00e9crire <code>struct Point<\/code>, juste <code>Point<\/code>.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"exemple-final-nombre-complexe\">Exemple final : nombre complexe<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Un <strong>nombre complexe<\/strong> a :<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>une partie r\u00e9elle (<code>re<\/code>)<\/li>\n\n\n\n<li>une partie imaginaire (<code>im<\/code>)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">D\u00e9claration :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>typedef struct {\n    float re;  \/\/ partie r\u00e9elle\n    float im;  \/\/ partie imaginaire\n} Complexe;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"exemple-complet-avec-addition-de-complexes\">Exemple complet avec addition de complexes<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n\n\/\/ D\u00e9finition du type Complexe\ntypedef struct {\n    float re;\n    float im;\n} Complexe;\n\n\/\/ Fonction d'addition\nComplexe addition(Complexe a, Complexe b) {\n    Complexe res;\n    res.re = a.re + b.re;\n    res.im = a.im + b.im;\n    return res;\n}\n\n\/\/ Affichage\nvoid afficher(Complexe z) {\n    printf(\"%.2f + %.2fi\\n\", z.re, z.im);\n}\n\nint main() {\n    Complexe z1 = {3.0, 2.0};\n    Complexe z2 = {1.5, -4.0};\n\n    Complexe somme = addition(z1, z2);\n\n    printf(\"z1 = \"); afficher(z1);\n    printf(\"z2 = \"); afficher(z2);\n    printf(\"z1 + z2 = \"); afficher(somme);\n\n    return 0;\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>z1 = 3.00 + 2.00i\nz2 = 1.50 + -4.00i\nz1 + z2 = 4.50 + -2.00i<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"resume\">R\u00e9sum\u00e9<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u00c9l\u00e9ment<\/th><th>Exemple<\/th><\/tr><\/thead><tbody><tr><td>D\u00e9claration<\/td><td><code>struct Complexe { float re, im; };<\/code><\/td><\/tr><tr><td>Variable<\/td><td><code>Complexe z;<\/code><\/td><\/tr><tr><td>Acc\u00e8s<\/td><td><code>z.re<\/code>, <code>z.im<\/code><\/td><\/tr><tr><td>Avantage<\/td><td>Organisation claire des donn\u00e9es<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"encore-un-exemple-la-multiplication-de-nombres-complexes\">Encore un exemple , la multiplication de nombres complexes <\/h1>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"objectif\">Objectif :<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>D\u00e9clarer une structure <code>Complexe<\/code><\/li>\n\n\n\n<li>Impl\u00e9menter :\n<ul class=\"wp-block-list\">\n<li>une fonction <code>afficher()<\/code><\/li>\n\n\n\n<li>une fonction <code>addition()<\/code><\/li>\n\n\n\n<li>une fonction <code>multiplication()<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Afficher les r\u00e9sultats<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"rappel-mathematique\">\ud83e\udde0 Rappel math\u00e9matique<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Si :<br><strong>z1 = a + bi<\/strong><br><strong>z2 = c + di<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Alors :<br><strong>z1 \u00d7 z2 = (ac &#8211; bd) + (ad + bc)i<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"code-complet-avec-multiplication\">Code complet avec multiplication :<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n#include &lt;stdlib.h>\n\n\/* D\u00e9finition d'un nombre complexe *\/\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#ff6900\" class=\"has-inline-color\">typedef struct {\n    float re;\n    float im;\n} Complexe;<\/mark>\n\n\/* Affiche un complexe *\/\nvoid afficher(Complexe z) \n{\n    printf(\"%.2f + %.2fi\\n\", z.re, z.im);\n}\n\n\/* Additionne deux complexes *\/\nComplexe addition(Complexe a, Complexe b) \n{\n    Complexe res;\n    res.re = a.re + b.re;\n    res.im = a.im + b.im;\n    return res;\n}\n\n\/* Multiplie deux complexes *\/\nComplexe multiplication(Complexe a, Complexe b) \n{\n    Complexe res;\n    res.re = a.re * b.re - a.im * b.im;\n    res.im = a.re * b.im + a.im * b.re;\n    return res;\n}\n\nint main() \n{\n    Complexe z1 = {2.0, 3.0};  \/* z1 = 2 + 3i *\/\n    Complexe z2 = {1.0, -4.0}; \/* z2 = 1 - 4i *\/\n\n    Complexe somme = addition(z1, z2);\n    Complexe produit = multiplication(z1, z2);\n\n    printf(\"z1 = \"); afficher(z1);\n    printf(\"z2 = \"); afficher(z2);\n\n    printf(\"z1 + z2 = \"); afficher(somme);\n    printf(\"z1 * z2 = \"); afficher(produit);\n\n    return EXIT_SUCCESS;\n}\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>z1 = 2.00 + 3.00i\nz2 = 1.00 + -4.00i\nz1 + z2 = 3.00 + -1.00i\nz1 * z2 = 14.00 + -5.00i<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Qu\u2019est-ce qu\u2019une structure ? En C, une structure (struct) est un type de donn\u00e9es qui permet de regrouper plusieurs variables (de types diff\u00e9rents ou identiques) sous un m\u00eame nom. [&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-2529","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 en langage C - 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-en-langage-c\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Les structures en langage C - workboot\" \/>\n<meta property=\"og:description\" content=\"1. Qu\u2019est-ce qu\u2019une structure ? En C, une structure (struct) est un type de donn\u00e9es qui permet de regrouper plusieurs variables (de types diff\u00e9rents ou identiques) sous un m\u00eame nom. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/workboot.fr\/ciela\/les-structures-en-langage-c\/\" \/>\n<meta property=\"og:site_name\" content=\"workboot\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-17T13:11:24+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/les-structures-en-langage-c\\\/\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/les-structures-en-langage-c\\\/\",\"name\":\"Les structures en langage C - workboot\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#website\"},\"datePublished\":\"2025-07-17T13:04:33+00:00\",\"dateModified\":\"2025-07-17T13:11:24+00:00\",\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/workboot.fr\\\/ciela\\\/les-structures-en-langage-c\\\/\"]}]},{\"@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 en langage C - 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-en-langage-c\/","og_locale":"fr_FR","og_type":"article","og_title":"Les structures en langage C - workboot","og_description":"1. Qu\u2019est-ce qu\u2019une structure ? En C, une structure (struct) est un type de donn\u00e9es qui permet de regrouper plusieurs variables (de types diff\u00e9rents ou identiques) sous un m\u00eame nom. [&hellip;]","og_url":"https:\/\/workboot.fr\/ciela\/les-structures-en-langage-c\/","og_site_name":"workboot","article_modified_time":"2025-07-17T13:11:24+00:00","twitter_misc":{"Dur\u00e9e de lecture estim\u00e9e":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/workboot.fr\/ciela\/les-structures-en-langage-c\/","url":"https:\/\/workboot.fr\/ciela\/les-structures-en-langage-c\/","name":"Les structures en langage C - workboot","isPartOf":{"@id":"https:\/\/workboot.fr\/ciela\/#website"},"datePublished":"2025-07-17T13:04:33+00:00","dateModified":"2025-07-17T13:11:24+00:00","inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/workboot.fr\/ciela\/les-structures-en-langage-c\/"]}]},{"@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. Qu\u2019est-ce qu\u2019une structure ? En C, une structure (struct) est un type de donn\u00e9es qui permet de regrouper plusieurs variables (de types diff\u00e9rents ou identiques) sous un m\u00eame nom. [&hellip;]","_links":{"self":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/2529","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=2529"}],"version-history":[{"count":2,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/2529\/revisions"}],"predecessor-version":[{"id":2533,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/2529\/revisions\/2533"}],"wp:attachment":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/media?parent=2529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}