{"id":2978,"date":"2024-11-21T17:56:07","date_gmt":"2024-11-21T09:56:07","guid":{"rendered":"https:\/\/guerilla.ddns.net\/wp\/?p=2978"},"modified":"2025-08-22T22:28:26","modified_gmt":"2025-08-22T14:28:26","slug":"const-char-stdstring-%e8%bd%89%e6%8f%9b","status":"publish","type":"post","link":"https:\/\/guerilla.ddns.net\/wp\/?p=2978","title":{"rendered":"C\/C++ const char* \/ std::string"},"content":{"rendered":"<h2>const char* convert to std::string:<\/h2>\r\n\r\n<pre class=\"wp-block-code\"><code class=\"language-cpp\" data-line=\"\">\nconst char *p = &quot;Welcome to GeeksForGeeks&quot;;\n\/\/ Conversion of char* to std::string using =\nstd::string str = p;\n\n<\/code><\/pre>\r\n\r\n<h2>std::string convert to const char*:<\/h2>\r\n\r\n<pre class=\"wp-block-code\"><code class=\"language-cpp\" data-line=\"\">\nstd::string str = &quot;hello&quot;;\nconst char* p = str.c_str();\n\n<\/code><\/pre>\r\n\r\nref:\r\n\u2022 <a href=\"https:\/\/www.geeksforgeeks.org\/convert-char-to-string-in-cpp\/\" target=\"_blank\">Convert char* to std::string in C++ &#8211; GeeksforGeeks<\/a>\r\n\u2022 <a href=\"https:\/\/stackoverflow.com\/questions\/11040703\/convert-unicode-to-char\" target=\"_blank\">c++ &#8211; convert unicode to char &#8211; Stack Overflow<\/a>\r\n\r\n#C++ #coding #convert #UTF8 #programming","protected":false},"excerpt":{"rendered":"<p>const char* convert to std::string: std::string convert [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[212],"tags":[85,27],"class_list":["post-2978","post","type-post","status-publish","format-standard","hentry","category-coding","tag-c","tag-coding"],"_links":{"self":[{"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2978","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2978"}],"version-history":[{"count":6,"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2978\/revisions"}],"predecessor-version":[{"id":3198,"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2978\/revisions\/3198"}],"wp:attachment":[{"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2978"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2978"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2978"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}