{"id":38,"date":"2021-06-05T20:18:24","date_gmt":"2021-06-05T12:18:24","guid":{"rendered":"https:\/\/swordofmorning.com\/?p=38"},"modified":"2025-10-09T13:56:21","modified_gmt":"2025-10-09T05:56:21","slug":"a-new-method-of-dividing-string-according-to-blank-characters-in-cpp","status":"publish","type":"post","link":"https:\/\/swordofmorning.com\/index.php\/2021\/06\/05\/a-new-method-of-dividing-string-according-to-blank-characters-in-cpp\/","title":{"rendered":"C++\u4e2d\u5c06string\u6309\u7167\u7a7a\u767d\u5b57\u7b26\u5206\u5272\u7684\u65b0\u65b9\u6cd5"},"content":{"rendered":"<pre><code class=\"language-cpp\">#include &lt;iostream&gt;\n#include &lt;string&gt;\n#include &lt;sstream&gt;\n#include &lt;vector&gt;\nusing namespace std;\n\nint main() {\n    \/\/\u7528\u4e8e\u5b58\u653e\u5206\u5272\u540e\u7684\u5b57\u7b26\u4e32\n    vector&lt;string&gt; res;\n    \/\/\u5f85\u5206\u5272\u7684\u5b57\u7b26\u4e32\uff0c\u542b\u6709\u5f88\u591a\u7a7a\u683c\n    string word = &quot;   Hello, I want   to learn C++!   &quot;;\n    \/\/\u6682\u5b58\u4eceword\u4e2d\u8bfb\u53d6\u7684\u5b57\u7b26\u4e32\n    string result;\n    \/\/\u5c06\u5b57\u7b26\u4e32\u8bfb\u5230input\u4e2d\n    stringstream input(word);\n    \/\/\u4f9d\u6b21\u8f93\u51fa\u5230result\u4e2d\uff0c\u5e76\u5b58\u5165res\u4e2d\n    while (input &gt;&gt; result)\n        res.push_back(result);\n    \/\/\u8f93\u51fares\n    for (int i = 0; i &lt; res.size(); i++) {\n        cout &lt;&lt; res[i] &lt;&lt; endl;\n    }\n    return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;ss &#8230;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48],"tags":[14],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts\/38"}],"collection":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":1,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"predecessor-version":[{"id":1047,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts\/38\/revisions\/1047"}],"wp:attachment":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}