{"id":69,"date":"2025-08-26T19:31:26","date_gmt":"2025-08-26T18:31:26","guid":{"rendered":"https:\/\/www.alarigger.com\/?p=69"},"modified":"2025-08-26T19:31:26","modified_gmt":"2025-08-26T18:31:26","slug":"bases-de-la-programmation-les-variables-de-type-string","status":"publish","type":"post","link":"https:\/\/www.alarigger.com\/?p=69","title":{"rendered":"\ud83e\udd16 Bases de la Programmation : Les Variables de type &#8220;string&#8221; part 1"},"content":{"rendered":"<!-- MetaSlider 875 not found -->\n\n\n\n<p class=\"wp-block-paragraph\">Les string sont des chaines de charact\u00e8res.  En informatique, un charact\u00e8re est un symbole graphique avec un code sp\u00e9cial. Il peut s&#8217;agir d&#8217;une lettre, d&#8217;un chiffre ou  m\u00eame d&#8217;un \u00e9motic\u00f4ne. La plupart des touches du clavier correspondent \u00e0 un charact\u00e8re ou &#8220;char&#8221;. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\ud83d\udc49 Une string est donc une liste de char. C&#8217;est LE type qui s&#8217;occupe de tout ce qui est valeurs textuelles en programmation. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>D\u00e9clarer une string <\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On d\u00e9clare une valeur string en mettant une serie de charact\u00e8re entre guillemets. Ces guillemets sont l\u00e0 pour dire \u00e0 l&#8217;ordinateur qu&#8217;il s&#8217;agit d&#8217;une valeur et non d&#8217;instructions de code. C&#8217;est exactement l&#8217;usage qu&#8217;on en fait lorsque qu&#8217;un personnage parle dans un roman. On utilise les guillemet pour distinguer la voix du narrateur de celle du personnage qui parle. <\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>var my_string = \"bonjour\"\nMessageBox.information(my_string)\n\/\/ affiche bonjour<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">var<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">my_string<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #CE9178\">&quot;bonjour&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">MessageBox<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #DCDCAA\">information<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">my_string<\/span><span style=\"color: #D4D4D4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A9955\">\/\/ affiche bonjour<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>L&#8217;op\u00e9rateur +<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On peut combiner des string entre elles gr\u00e2ce \u00e0 l&#8217;op\u00e9rateur + comme ceci :<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>var my_string = \"bonjour \"\nvar ville= \" angouleme\" \nvar phrase= my_string + ville\nMessageBox.information(phrase)\n\/\/ affiche bonjour angouleme \n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">var<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">my_string<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #CE9178\">&quot;bonjour &quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">var<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">ville<\/span><span style=\"color: #D4D4D4\">= <\/span><span style=\"color: #CE9178\">&quot; angouleme&quot;<\/span><span style=\"color: #D4D4D4\"> <\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">var<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">phrase<\/span><span style=\"color: #D4D4D4\">= <\/span><span style=\"color: #9CDCFE\">my_string<\/span><span style=\"color: #D4D4D4\"> + <\/span><span style=\"color: #9CDCFE\">ville<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">MessageBox<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #DCDCAA\">information<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">phrase<\/span><span style=\"color: #D4D4D4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A9955\">\/\/ affiche bonjour angouleme <\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">En javascript le type string est &#8220;contagieux&#8221; . C&#8217;est \u00e0 dire qu&#8217;il convertit tout ce qu&#8217;on lui additionne en type string <\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>var my_string = \"abdc\"+\nvar my_int = 123\nMessageBox.information( my_string + my_int )\n\/\/ affiche abcd123 my_int a \u00e9t\u00e9 trait\u00e9 comme une string \n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">var<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">my_string<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #CE9178\">&quot;abdc&quot;<\/span><span style=\"color: #D4D4D4\">+<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">var<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">my_int<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #B5CEA8\">123<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">MessageBox<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #DCDCAA\">information<\/span><span style=\"color: #D4D4D4\">( <\/span><span style=\"color: #9CDCFE\">my_string<\/span><span style=\"color: #D4D4D4\"> + <\/span><span style=\"color: #9CDCFE\">my_int<\/span><span style=\"color: #D4D4D4\"> )<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A9955\">\/\/ affiche abcd123 my_int a \u00e9t\u00e9 trait\u00e9 comme une string <\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Les string sont des chaines de charact\u00e8res. En informatique, un charact\u00e8re est un symbole graphique avec un code sp\u00e9cial. Il peut s&#8217;agir d&#8217;une lettre, d&#8217;un chiffre ou m\u00eame d&#8217;un \u00e9motic\u00f4ne. La plupart des touches du clavier correspondent \u00e0 un charact\u00e8re ou &#8220;char&#8221;. \ud83d\udc49 Une string est donc une liste de char. C&#8217;est LE type qui [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,4,37,28],"tags":[],"class_list":["post-69","post","type-post","status-publish","format-standard","hentry","category-bases_programmation","category-cour","category-string","category-variables"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.alarigger.com\/index.php?rest_route=\/wp\/v2\/posts\/69","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.alarigger.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.alarigger.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.alarigger.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.alarigger.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=69"}],"version-history":[{"count":0,"href":"https:\/\/www.alarigger.com\/index.php?rest_route=\/wp\/v2\/posts\/69\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.alarigger.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=69"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.alarigger.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=69"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.alarigger.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=69"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}