lang:cpp:string
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| lang:cpp:string [2023/01/30 09:42] – Ajout de consteval avec std::string_view root | lang:cpp:string [2025/08/27 13:47] (Version actuelle) – [stringstream] : ajout de "Concaténation de string" root | ||
|---|---|---|---|
| Ligne 15: | Ligne 15: | ||
| [[https:// | [[https:// | ||
| + | |||
| + | * Conversion entre string et wstring | ||
| + | |||
| + | Sous windows : | ||
| + | |||
| + | <code cpp> | ||
| + | std:: | ||
| + | { | ||
| + | int slength = (int)s.length() + 1; | ||
| + | int len = MultiByteToWideChar(CP_ACP, | ||
| + | std:: | ||
| + | MultiByteToWideChar(CP_ACP, | ||
| + | return r; | ||
| + | } | ||
| + | |||
| + | std::string ws2s(const std:: | ||
| + | { | ||
| + | int slength = (int)s.length() + 1; | ||
| + | int len = WideCharToMultiByte(CP_ACP, | ||
| + | std::string r(len, ' | ||
| + | WideCharToMultiByte(CP_ACP, | ||
| + | return r; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | [[https:// | ||
| ====stringstream=== | ====stringstream=== | ||
| + | |||
| + | ===Concaténation de string=== | ||
| + | |||
| + | <code cpp> | ||
| + | std:: | ||
| + | ss << " | ||
| + | ss.str(); | ||
| + | </ | ||
| + | |||
| + | Ou en utilisant '' | ||
| + | |||
| + | <code cpp> | ||
| + | std::string coucou = " | ||
| + | |||
| + | std:: | ||
| + | </ | ||
| + | |||
| + | ===char=== | ||
| + | |||
| Le résultat ne va pas être le même si on donne à '' | Le résultat ne va pas être le même si on donne à '' | ||
| - | | + | <code cpp> |
| + | ss << static_cast< | ||
| + | </ | ||
| va donner '' | va donner '' | ||
| - | | + | <code cpp> |
| + | ss << static_cast< | ||
| + | </ | ||
| va donner '' | va donner '' | ||
| Ligne 60: | Ligne 109: | ||
| </ | </ | ||
| - | [[https:// | + | [[https:// |
| ====Split==== | ====Split==== | ||
| ===string=== | ===string=== | ||
lang/cpp/string.1675068125.txt.gz · Dernière modification : de root
