{"id":230,"date":"2014-07-23T05:41:32","date_gmt":"2014-07-23T14:41:32","guid":{"rendered":"http:\/\/blog.box.kr\/?p=230"},"modified":"2014-07-23T05:41:32","modified_gmt":"2014-07-23T14:41:32","slug":"stdstring-%eb%8b%a4%eb%a3%a8%ea%b8%b0-%ec%b0%be%ea%b8%b0-%ea%b3%b5%eb%b0%b1%ec%a0%9c%ea%b1%b0-%eb%93%b1%eb%93%b1","status":"publish","type":"post","link":"https:\/\/blog.box.kr\/?p=230","title":{"rendered":"std::string \ub2e4\ub8e8\uae30.. ( \ucc3e\uae30, \uacf5\ubc31\uc81c\uac70 \ub4f1\ub4f1)"},"content":{"rendered":"<p><b style=\"color: #565656;\">\ubb38\uc790\uc5f4 string<\/b><br style=\"color: #565656;\" \/><br style=\"color: #565656;\" \/><\/p>\n<div style=\"color: #565656;\">#include &#8220;StdAfx.h&#8221;\n<\/div>\n<div style=\"color: #565656;\">#include &#8220;StringTest.h&#8221;\n<\/div>\n<div style=\"color: #565656;\">#include &lt;algorithm&gt; \/\/transform \uc0ac\uc6a9\n<\/div>\n<div style=\"color: #565656;\">#include &lt;functional&gt; \/\/bind1st\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">using std::string; \/\/ \uc774\ub807\uac8c \uc9c0\uc815\ud574\uc900\ub2e4.\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">StringTest::StringTest()\n<\/div>\n<div style=\"color: #565656;\">{\n<\/div>\n<div style=\"color: #565656;\">log(&#8220;StringTest \uc0dd\uc131\uc790 \ud638\ucd9c&#8221;);\n<\/div>\n<div style=\"color: #565656;\">}\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">StringTest::~StringTest(void)\n<\/div>\n<div style=\"color: #565656;\">{\n<\/div>\n<div style=\"color: #565656;\">log(&#8220;StringTest \uc18c\uba78\uc790 \ud638\ucd9c&#8221;);\n<\/div>\n<div style=\"color: #565656;\">}\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">void StringTest::test()\n<\/div>\n<div style=\"color: #565656;\">{\n<\/div>\n<div style=\"color: #565656;\">log(&#8220;============ string class ==========&#8221;);\n<\/div>\n<div style=\"color: #565656;\"><b>\/\/ \uc0dd\uc131\uc790<\/b>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div class=\"txc-textbox\" style=\"color: #565656;\">\n<p>&nbsp;<\/p>\n<div>\n<p>std::string s0; \/\/ \ube44\uc5b4\uc788\ub294 string\n<\/p><\/div>\n<div>\n<p>std::string s1(&#8220;012345&#8221;,3); \/\/ \uacb0\uacfc: 012\n<\/p><\/div>\n<div>\n<p>std::string s2(&#8220;abcdefg&#8221;,0,1); \/\/ \uacb0\uacfc:a\n<\/p><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">log(&#8220;\ube44\uc5b4 \uc788\ub294 String=%s, length=%d, isEmpty=%d&#8221;,s0.c_str(),s0.length(), s0.empty()); \/\/ C-String \ud615\uc73c\ub85c \ub9ac\ud134, \ubb38\uc790\uc5f4 + \u0000\n<\/div>\n<div style=\"color: #565656;\">log(&#8220;\ubb38\uc790\uc5f4\ub85c \ucd08\uae30\ud654=%s&#8221;,s1.data()); \/\/ \ubb38\uc790\uc5f4 \ub0b4\uc6a9 \ubc18\ud658\n<\/div>\n<div style=\"color: #565656;\">log(&#8220;\ubb38\uc790\uc5f4\uc758 index~index \uc548 \ub370\uc774\ud130\ub85c \uc0dd\uc131=%s&#8221;,s2.c_str());\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><b>\/\/ \ubb38\uc790\uc5f4 \uae30\ubcf8\uc815\ubcf4<\/b>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div class=\"txc-textbox\" style=\"color: #565656;\">\n<p>&nbsp;<\/p>\n<div>\n<p>s1.reserve(100); \/\/ \uba54\ubaa8\ub9ac \uacf5\uac04 \ubbf8\ub9ac \ud560\ub2f9\n<\/p><\/div>\n<div>\n<p>log(&#8220;\uac00\uc9c8\uc218\uc788\ub294 \ubb38\uc790 \ucd5c\ub300 \uac2f\uc218=%d&#8221;,s1.max_size());\n<\/p><\/div>\n<div>\n<p>log(&#8220;\uba54\ubaa8\ub9ac \uc7ac\ud560\ub2f9 \uc5c6\uc774 \uac00\uc9c8\uc218 \uc788\ub294 \ucd5c\ub300 \ubb38\uc790\uc218 =%d&#8221;,s1.capacity());\n<\/p><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><b>\/\/ \ubb38\uc790 \ucd94\uac00<\/b>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div class=\"txc-textbox\" style=\"color: #565656;\">\n<p>&nbsp;<\/p>\n<div>\n<p>s1 = &#8220;0123456&#8221;;\n<\/p><\/div>\n<div>\n<p>s2 = &#8220;abcdefg&#8221;;\n<\/p><\/div>\n<div>\n<p>s1.append(s2,0,s2.npos); \/\/ \uacb0\uacfc: 0123456abcdefg , s2\uc758 0~s2.npos \uc704\uce58\uc758 \ubb38\uc790\uc5f4\uc744 \ub9e8\ub4a4\uc5d0 \ucd94\uac00\n<\/p><\/div>\n<div>\n<p>s1.insert(0,&#8221;add&#8221;); \/\/ \uacb0\uacfc: add0123456abcdefg. \ubb38\uc790\uc5f4\uc744 0\ubc88\uc9f8\uc5d0 \ub07c\uc5b4\ub123\uae30\n<\/p><\/div>\n<div>\n<p>log(&#8220;append=%s&#8221;,s1.c_str());\n<\/p><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><b>\/\/ \ubb38\uc790 \ubcf5\uc0ac<\/b>\u00a0copy ( s1 -&gt; s4 \ub85c \ubcf5\uc0ac) char* s, size_t n, size_t pos = 0\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div class=\"txc-textbox\" style=\"color: #565656;\">\n<p>&nbsp;<\/p>\n<div>\n<p>char s4[100];\n<\/p><\/div>\n<div>\n<p>int length = s1.copy(s4,s1.length(), 0);\n<\/p><\/div>\n<div>\n<p>s4[length] = &#8216;\u0000&#8217;;\n<\/p><\/div>\n<div>\n<p>log(&#8220;copy=%s&#8221;,s4); \/\/ \uacb0\uacfc: 1234567\n<\/p><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><b>\/\/ \ubb38\uc790\uc5f4 \uc6d0\uc18c \uc811\uadfc<\/b>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div class=\"txc-textbox\" style=\"color: #565656;\">\n<p>&nbsp;<\/p>\n<div>\n<p>s1 =&#8221;0123456&#8243;;\n<\/p><\/div>\n<div>\n<p>log(&#8220;0\ubc88\uc9f8 \ubb38\uc790 = %c, %c&#8221;,s1.at(0), s1[1]); \/\/ \uacb0\uacfc:0,1 =&gt;\ubb38\uc790 \uc811\uadfc (\uc624\ubc84\uc2dc exception \ubc1c\uc0dd)\n<\/p><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><b>\/\/ \ubb38\uc790 \uc81c\uac70<\/b>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div class=\"txc-textbox\" style=\"color: #565656;\">\n<p>&nbsp;<\/p>\n<div>\n<p>s1 = &#8220;0123456&#8221;;\n<\/p><\/div>\n<div>\n<p>s1.erase(1); \/\/ \uacb0\uacfc:0\n<\/p><\/div>\n<div>\n<p>log(&#8220;2\ubc88\uc9f8 \ubb38\uc790\ubd80\ud130 \uc81c\uac70=%s&#8221;,s1.data()); \/\/ \ubb38\uc790 \uc811\uadfc (\uc624\ubc84\uc2dc exception \ubc1c\uc0dd)\n<\/p><\/div>\n<div>\n<p>s1.empty();\n<\/p><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><b>\/\/ \ubb38\uc790\uc5f4 \ud560\ub2f9 (\ubb38\uc790\uc5f4, \ud3ec\uc9c0\uc158, \uac2f\uc218)<\/b>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div class=\"txc-textbox\" style=\"color: #565656;\">\n<p>&nbsp;<\/p>\n<div>\n<p>s1 = &#8220;0123456&#8221;;\n<\/p><\/div>\n<div>\n<p>s1.assign(&#8220;abcdef&#8221;,0,3); \/\/ \uacb0\uacfc: abc, 0\ubc88\uc9f8 \ubd80\ud130 3\uac1c\ubb38\uc790\ub97c \ud560\ub2f9\n<\/p><\/div>\n<div>\n<p>log(&#8220;assign \ubb38\uc790\uc5f4 \ud560\ub2f9 = %s&#8221;,s1.data());\n<\/p><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><b>\/\/ \ubb38\uc790\uc5f4 \uad50\uccb4<\/b>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div class=\"txc-textbox\" style=\"color: #565656;\">\n<p>&nbsp;<\/p>\n<div>\n<p>s1 = &#8220;abcdef&#8221;;\n<\/p><\/div>\n<div>\n<p>s2=&#8221;0123456&#8243;;\n<\/p><\/div>\n<div>\n<p>s1.replace(0,1,&#8221;5555&#8243;); \/\/ \uacb0\uacfc: 5555bcdef\n<\/p><\/div>\n<div>\n<p>s1.swap(s2); \/\/ \uacb0\uacfc: s1=0123456, s2 = 5555bcdef\n<\/p><\/div>\n<div>\n<p>log(&#8220;\ubb38\uc790\uc5f4 \uad50\uccb4 s1=%s, s2=%s&#8221;,s1.data(),s2.data());\n<\/p><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><b>\/\/ substring<\/b>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div class=\"txc-textbox\" style=\"color: #565656;\">\n<p>&nbsp;<\/p>\n<div>\n<p>s1 = &#8220;0123456&#8221;;\n<\/p><\/div>\n<div>\n<p>s1 = s1.substr(0,3); \/\/ \uacb0\uacfc: 012, 0\ubc88\uc9f8\ubd80\ud130 3\uac1c\ubb38\uc790\ub97c \uc9e4\ub77c \ud560\ub2f9\ud55c\ub2e4.\n<\/p><\/div>\n<div>\n<p>log(&#8220;substr s1=%s&#8221;,s1.data());\n<\/p><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><b>\/\/ search<\/b>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div class=\"txc-textbox\" style=\"color: #565656;\">\n<p>&nbsp;<\/p>\n<div>\n<p>s1 = &#8220;01234560123456&#8221;;\n<\/p><\/div>\n<div>\n<p>int index = s1.find(&#8220;2&#8221;,0); \u00a0\/\/ \uacb0\uacfc :2, 0\ubc88\uc9f8 \uc704\uce58\ubd80\ud130 \uac80\uc0c9\ud574\uc11c 2\uc758 \uc704\uce58\ub97c \ucc3e\ub294\ub2e4.\n<\/p><\/div>\n<div>\n<p>int index2 = s1.rfind(&#8220;2&#8221;); \u00a0\/\/ \uacb0\uacfc :9, \ub05d\uc5d0\uc11c \ubd80\ud130 \uac80\uc0c9\ud574\uc11c 2\uc758 \uc704\uce58\ub97c \ucc3e\ub294\ub2e4.\n<\/p><\/div>\n<div>\n<p>int index3 = s1.find_first_of(&#8220;13&#8221;); \/\/ \uacb0\uacfc : 1, 1 or 3\uc774 \uc788\ub294 \uccab\ubc88\uc9f8 \uc704\uce58\ub97c \ucc3e\ub294\ub2e4.\n<\/p><\/div>\n<div>\n<p>int index4 = s1.find_last_of(&#8220;13&#8221;); \/\/ \uacb0\uacfc : \u00a010, 1 or 3\uc774 \uc788\ub294 \ub9c8\uc9c0\ub9c9 \uc704\uce58\ub97c \ucc3e\ub294\ub2e4.\n<\/p><\/div>\n<div>\n<\/div>\n<div>\n<p>int index5 = s1.find_first_not_of(&#8220;0&#8221;); \/\/ \uacb0\uacfc : 1, 0\uc774 \uc544\ub2cc \ubb38\uc790\uac00 \ub098\uc624\ub294 \uccab\ubc88\uc9f8 \uc704\uce58\n<\/p><\/div>\n<div>\n<p>int index6 = s1.find_last_not_of(&#8220;6&#8221;); \/\/ \uacb0\uacfc : 5, 0\uc774 \uc544\ub2cc \ubb38\uc790\uac00 \ub098\uc624\ub294 \ub9c8\uc9c0\ub9c9 \uc704\uce58\n<\/p><\/div>\n<div>\n<\/div>\n<div>\n<p>\/\/ \uac80\uc0c9 \uc2e4\ud328\uc2dc std::string::npos \ub97c \ub9ac\ud134\ud55c\ub2e4. std::string::size_type \ud615\uc774\ub2e4.\n<\/p><\/div>\n<div>\n<p>log(&#8220;search find=%d, rfind=%d, find_first_of=%d, find_last_of=%d, find_first_not_of=%d,find_first_not_of=%d&#8221;,index,index2,index3, index4,index5, index6);\n<\/p><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">\/\/ \ubc18\ubcf5\uc790\n<\/div>\n<div style=\"color: #565656;\">ConvertCase();\n<\/div>\n<div style=\"color: #565656;\">}\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><b>\/\/ \ubc18\ubcf5\uc790 \uc774\uc6a9<\/b>\n<\/div>\n<div style=\"color: #565656;\">void StringTest::ConvertCase(){\n<\/div>\n<div style=\"color: #565656;\"><span style=\"color: #e31600;\">\/\/\uae30\ubcf8 (\uc601\uc5b4\ub9cc \uac00\ub2a5)<\/span>\n<\/div>\n<div style=\"color: #565656;\">char str[] = &#8220;abcdefg&#8221;;\n<\/div>\n<div style=\"color: #565656;\">strupr(str); \/\/ strlwr\n<\/div>\n<div style=\"color: #565656;\">log(&#8220;\ub300\uc18c\ubb38\uc790 \ubcc0\ud658=%s&#8221;,str);\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><span style=\"color: #e31600;\">\/\/ custom \uc0ac\uc6a9<\/span>\n<\/div>\n<div style=\"color: #565656;\">\/\/std::string msg0(&#8220;abcdefg&#8221;);\n<\/div>\n<div style=\"color: #565656;\">\/\/std::transform(msg0.begin(), msg0.end(), msg0.begin(), toUpper);\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><span style=\"color: #e31600;\">\/\/ string \ubc18\ubcf5\uc790 \uc774\uc6a9 (\uc601\uc5b4\ub9cc \uac00\ub2a5)<\/span>\n<\/div>\n<div style=\"color: #565656;\">std::string msg(&#8220;abcdefg&#8221;);\n<\/div>\n<div style=\"color: #565656;\">std::transform(msg.begin(), msg.end(), msg.begin(), toupper);\n<\/div>\n<div style=\"color: #565656;\">log(&#8220;\ub300\uc18c\ubb38\uc790 \ubcc0\ud658=%s&#8221;,msg.data());\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><span style=\"color: #e31600;\">\/\/locale \uc774\uc6a9 (\ubaa8\ub4e0 \ub098\ub77c \uac00\ub2a5)<\/span>\n<\/div>\n<div style=\"color: #565656;\">char* org_lc = setlocale(LC_CTYPE, NULL); \/\/\ud604\uc7ac locale \uc800\uc7a5\n<\/div>\n<div style=\"color: #565656;\">setlocale(LC_CTYPE, &#8220;spanish&#8221;);\n<\/div>\n<div style=\"color: #565656;\">std::wstring str2(L&#8221;peque\u00f1o&#8221;);\n<\/div>\n<div style=\"color: #565656;\">std::transform( str2.begin(), str2.end(), str2.begin(), towupper);\n<\/div>\n<div style=\"color: #565656;\">setlocale(LC_CTYPE, org_lc);\n<\/div>\n<div style=\"color: #565656;\">log(&#8220;locale \uc774\uc6a9 \ub300\uc18c\ubb38\uc790 \ubcc0\ud658=%s&#8221;,str2.data());\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><span style=\"color: #e31600;\">\/\/facet \uc774\uc6a9 \ubcc0\ud658 (\ubaa8\ub4e0 \ub098\ub77c \uac00\ub2a5)<\/span>\n<\/div>\n<div style=\"color: #565656;\">std::locale loc(&#8220;spanish&#8221;);\n<\/div>\n<div style=\"color: #565656;\">const std::ctype&lt;wchar_t&gt;&amp; ct = std::use_facet&lt;std::ctype&lt;wchar_t&gt; &gt;(loc);\n<\/div>\n<div style=\"color: #565656;\">std::wstring str3(L&#8221;peque\u00f1o&#8221;);\n<\/div>\n<div style=\"color: #565656;\">std::transform(str3.begin(), str3.end(), str3.begin(),\n<\/div>\n<div style=\"color: #565656;\">std::bind1st(std::mem_fun(&amp;std::ctype&lt;wchar_t&gt;::toupper), &amp;ct));\n<\/div>\n<div style=\"color: #565656;\">log(&#8220;facet \uc774\uc6a9 \ub300\uc18c\ubb38\uc790 \ubcc0\ud658=%s&#8221;,str3.data());\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><span style=\"color: #e31600;\">\/\/ \ubc18\ubcf5\uc790 \uc774\uc6a9\ud55c \ucd9c\ub825<\/span>\n<\/div>\n<div style=\"color: #565656;\">msg = &#8220;abcdefg&#8221;;\n<\/div>\n<div style=\"color: #565656;\">string::iterator it;\n<\/div>\n<div style=\"color: #565656;\">cout&lt;&lt;&#8220;\ubc18\ubcf5\uc790 \uc774\uc6a9\ud55c \ucd9c\ub825=&#8221;;\n<\/div>\n<div style=\"color: #565656;\">for(it=msg.begin(); it!=msg.end(); ++it) {\n<\/div>\n<div style=\"color: #565656;\">cout&lt;&lt;*it;\n<\/div>\n<div style=\"color: #565656;\">}\n<\/div>\n<div style=\"color: #565656;\">cout&lt;&lt;endl;\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><span style=\"color: #e31600;\">\/\/ \ubaa8\ub4e0 \ubb38\uc790\ub4e4\uc758 \uc21c\uc11c \ubcc0\uacbd<\/span>\n<\/div>\n<div style=\"color: #565656;\">msg = &#8220;gfedcba&#8221;;\n<\/div>\n<div style=\"color: #565656;\">std::reverse(msg.begin(), msg.end());\n<\/div>\n<div style=\"color: #565656;\">log(&#8220;\uc21c\uc11c \ubc14\uafb8\uae30=%s&#8221;,msg.data());\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><span style=\"color: #e31600;\">\/\/ \ubb38\uc790 \uc815\ub82c<\/span>\n<\/div>\n<div style=\"color: #565656;\">std::sort(msg.begin(), msg.end());\n<\/div>\n<div style=\"color: #565656;\">log(&#8220;\ubb38\uc790 \uc815\ub82c=%s&#8221;,msg.data());\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><span style=\"color: #e31600;\">\/\/ \uc5f0\uc18d\ub41c \ubb38\uc790 \uc81c\uac70<\/span>\n<\/div>\n<div style=\"color: #565656;\">msg = &#8220;1223334444&#8221;;\n<\/div>\n<div style=\"color: #565656;\">msg.erase(<span style=\"color: #e31600;\">std::unique<\/span>(msg.begin(), msg.end()), msg.end());\n<\/div>\n<div style=\"color: #565656;\">log(&#8220;\uc5f0\uc18d\ub41c \ubb38\uc790 \uc81c\uac70=%s&#8221;,msg.data());\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\">}\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><span style=\"color: #e31600;\">\/\/\ub300\ubb38\uc790\ub97c \uc18c\ubb38\uc790\ub85c \ubcc0\ud658\ud558\ub294 \ud568\uc218 (\uc601\uc5b4\ub9cc \uac00\ub2a5)<\/span>\n<\/div>\n<div style=\"color: #565656;\">char StringTest::toLower(char elem){\n<\/div>\n<div style=\"color: #565656;\">if(elem&gt;=&#8217;A&#8217; &amp;&amp; elem&lt;=&#8217;Z&#8217;)return elem+(&#8216;a&#8217;-&#8216;A&#8217;);\n<\/div>\n<div style=\"color: #565656;\">return elem;\n<\/div>\n<div style=\"color: #565656;\">}\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><span style=\"color: #e31600;\">\/\/\uc18c\ubb38\uc790\ub97c \ub300\ubb38\uc790\ub85c \ubcc0\ud658\ud558\ub294 \ud568\uc218 (\uc601\uc5b4\ub9cc \uac00\ub2a5)<\/span>\n<\/div>\n<div style=\"color: #565656;\">char StringTest::toUpper(char elem){\n<\/div>\n<div style=\"color: #565656;\">if(elem&gt;=&#8217;a&#8217; &amp;&amp; elem&lt;=&#8217;z&#8217;)return elem-(&#8216;a&#8217;-&#8216;A&#8217;);\n<\/div>\n<div style=\"color: #565656;\">return elem;\n<\/div>\n<div style=\"color: #565656;\">}\n<\/div>\n<div style=\"color: #565656;\">\n<\/div>\n<div style=\"color: #565656;\"><span style=\"color: #e31600;\">\/\/\ub300 \uc18c\ubb38\uc790 \uad6c\ubcc4\uc5c6\uc774 \uc77c\uce58\uc5ec\ubd80 \ud310\ub2e8<\/span>\n<\/div>\n<div style=\"color: #565656;\">char StringTest::equlasIgnoreCase(char c1, char c2){\n<\/div>\n<div style=\"color: #565656;\">return toUpper(c1)==toUpper(c2);\n<\/div>\n<p><span style=\"color: #565656;\">}\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ubb38\uc790\uc5f4 string #include &#8220;StdAfx.h&#8221; #include &#8220;StringTest.h&#8221; #include &lt;algorithm&gt; \/\/transform \uc0ac\uc6a9 #include &lt;functional&gt; \/\/bind1st using std::string; \/\/ \uc774\ub807\uac8c \uc9c0\uc815\ud574\uc900\ub2e4. StringTest::StringTest() { log(&#8220;StringTest \uc0dd\uc131\uc790 \ud638\ucd9c&#8221;); } StringTest::~StringTest(void) { log(&#8220;StringTest \uc18c\uba78\uc790 \ud638\ucd9c&#8221;); } void StringTest::test() { log(&#8220;============ string class ==========&#8221;); \/\/ \uc0dd\uc131\uc790 &nbsp; std::string s0; \/\/ \ube44\uc5b4\uc788\ub294 string std::string s1(&#8220;012345&#8221;,3); \/\/ \uacb0\uacfc: 012 std::string s2(&#8220;abcdefg&#8221;,0,1); \/\/ \uacb0\uacfc:a &nbsp; log(&#8220;\ube44\uc5b4 \uc788\ub294 String=%s, length=%d, isEmpty=%d&#8221;,s0.c_str(),s0.length(), s0.empty()); \/\/ C-String \ud615\uc73c\ub85c \ub9ac\ud134, \ubb38\uc790\uc5f4 + log(&#8220;\ubb38\uc790\uc5f4\ub85c \ucd08\uae30\ud654=%s&#8221;,s1.data()); \/\/ \ubb38\uc790\uc5f4 \ub0b4\uc6a9 \ubc18\ud658 log(&#8220;\ubb38\uc790\uc5f4\uc758 index~index \uc548 \ub370\uc774\ud130\ub85c \uc0dd\uc131=%s&#8221;,s2.c_str()); \/\/ \ubb38\uc790\uc5f4 \uae30\ubcf8\uc815\ubcf4 &nbsp; s1.reserve(100); \/\/ \uba54\ubaa8\ub9ac \uacf5\uac04 \ubbf8\ub9ac \ud560\ub2f9 log(&#8220;\uac00\uc9c8\uc218\uc788\ub294 \ubb38\uc790 \ucd5c\ub300 \uac2f\uc218=%d&#8221;,s1.max_size()); log(&#8220;\uba54\ubaa8\ub9ac \uc7ac\ud560\ub2f9 \uc5c6\uc774 \uac00\uc9c8\uc218 \uc788\ub294 \ucd5c\ub300 \ubb38\uc790\uc218 =%d&#8221;,s1.capacity()); &nbsp; \/\/ \ubb38\uc790 \ucd94\uac00 &nbsp; s1 = &#8220;0123456&#8221;; s2 = &#8220;abcdefg&#8221;; s1.append(s2,0,s2.npos); \/\/ \uacb0\uacfc: 0123456abcdefg , s2\uc758 0~s2.npos \uc704\uce58\uc758 \ubb38\uc790\uc5f4\uc744 \ub9e8\ub4a4\uc5d0 \ucd94\uac00 s1.insert(0,&#8221;add&#8221;); \/\/ \uacb0\uacfc: add0123456abcdefg. \ubb38\uc790\uc5f4\uc744 0\ubc88\uc9f8\uc5d0 \ub07c\uc5b4\ub123\uae30 log(&#8220;append=%s&#8221;,s1.c_str()); &nbsp; \/\/ \ubb38\uc790 \ubcf5\uc0ac\u00a0copy ( s1 -&gt; s4 \ub85c \ubcf5\uc0ac) char* s, size_t n, size_t pos = 0 &nbsp; char s4[100]; int length = s1.copy(s4,s1.length(), 0); s4[length] = &#8216;&#8217;; log(&#8220;copy=%s&#8221;,s4); \/\/ \uacb0\uacfc: 1234567 &nbsp; \/\/ \ubb38\uc790\uc5f4 \uc6d0\uc18c \uc811\uadfc &nbsp; s1 =&#8221;0123456&#8243;; log(&#8220;0\ubc88\uc9f8 \ubb38\uc790 = %c, %c&#8221;,s1.at(0), s1[1]); \/\/ \uacb0\uacfc:0,1 =&gt;\ubb38\uc790 \uc811\uadfc (\uc624\ubc84\uc2dc exception \ubc1c\uc0dd) &nbsp; \/\/ \ubb38\uc790 \uc81c\uac70 &nbsp; s1 = &#8220;0123456&#8221;; s1.erase(1); \/\/ \uacb0\uacfc:0 log(&#8220;2\ubc88\uc9f8 \ubb38\uc790\ubd80\ud130 \uc81c\uac70=%s&#8221;,s1.data()); \/\/ \ubb38\uc790 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"ngg_post_thumbnail":0,"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[9,19,7],"tags":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5q9Zn-3I","jetpack-related-posts":[{"id":220,"url":"https:\/\/blog.box.kr\/?p=220","url_meta":{"origin":230,"position":0},"title":"VARIANT to std::string","date":"2014-07-23","format":false,"excerpt":"Here's one way, not necessarily the best. In general, std::string doesn't play very well with VARIANT. #include <comutil.h> #include <string> std::string from_variant(VARIANT& vt) { _bstr_t bs(vt); return std::string(static_cast<const char*>(bs)); } void to_variant(const std::string& str, VARIANT& vt) { _bstr_t bs(str.c_str()); reinterpret_cast<_variant_t&>(vt) = bs; } \u00a0 \ub610\ud55c.. VARIANT\uac00 \ube44\uc5b4 \uc788\ub294\uc9c0 \ud655\uc778 \ud558\ub294\u2026","rel":"","context":"In &quot;C\/C++&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":339,"url":"https:\/\/blog.box.kr\/?p=339","url_meta":{"origin":230,"position":1},"title":"[c++11] \uc798 \uc4f0\uba74 \ub9e4\uc6b0 \ud3b8\ub9ac\ud55c C++11\uc758 \ubb38\ubc95\ub4e4","date":"2014-08-12","format":false,"excerpt":"C\/C++\uc5b8\uc5b4\ub294 \uc800\uc218\uc900\uae4c\uc9c0 \uc815\ubc00\ud558\uac8c \ub2e4\ub8f0 \uc218 \uc788\ub294 \ubc18\uba74, \ud504\ub85c\uadf8\ub798\uba38\uac00 \uc77c\uc77c\ud788 \uad00\ub9ac\ud574\uc918\uc57c\ud558\ub294 \ubd80\ubd84\uc774 \ub9ce\ub2e4\ub294\uac8c C\/C++\uc5b8\uc5b4\uc5d0 \ub300\ud55c \uc77c\ubc18\uc801\uc778 \uacac\ud574\uc785\ub2c8\ub2e4. \uadf8\ub798\uc11c \uc800\uc218\uc900\uae4c\uc9c0 \uc77c\uc77c\ud788 \uc2e0\uacbd\uc4f0\uc9c0 \uc54a\uc544\ub3c4 \ub418\ub294 \ucfe8\ud55c \uc5b8\uc5b4\ub97c \uac00\uc9c0\uace0 \ub192\uc740 \uc0dd\uc0b0\uc131\uc744 \ucd94\uad6c\ud558\ub294\uac8c \ucd94\uc138\uc774\uae30\ub3c4 \ud569\ub2c8\ub2e4. . . . \ub9cc, C++\uc758 \uace8\uc218\ube60\ub85c\uc11c C++11\uc744 \ud1b5\ud574 C++\ub85c\ub3c4 \ucda9\ubd84\ud788 \ucfe8\ud558\uace0 \uc0dd\uc0b0\uc131 \ub192\uc740 \ucf54-\ub4dc\ub97c \uc791\uc131\ud560\uc218 \uc788\ub2e4\uace0 \ubcc0\ud638\ub97c \ud574\ubcf4\ub824\uace0 \ud569\ub2c8\ub2e4. Visual\u2026","rel":"","context":"In &quot;C\/C++&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":178,"url":"https:\/\/blog.box.kr\/?p=178","url_meta":{"origin":230,"position":2},"title":"std::map example","date":"2014-07-09","format":false,"excerpt":"\/\/ std::map example \/\/ opposite words #include <iostream> #include <map> #include <string> using namespace std; typedef std::map<std::string, std::string> TStrStrMap; typedef std::pair<std::string, std::string> TStrStrPair; int main(int argc, char *argv[]) { TStrStrMap tMap; tMap.insert(TStrStrPair(\"yes\", \"no\")); tMap.insert(TStrStrPair(\"up\", \"down\")); tMap.insert(TStrStrPair(\"left\", \"right\")); tMap.insert(TStrStrPair(\"good\", \"bad\")); std::string s; std::cout << \"Enter word: \" << std::endl;; std::cin >>\u2026","rel":"","context":"In &quot;C\/C++&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":228,"url":"https:\/\/blog.box.kr\/?p=228","url_meta":{"origin":230,"position":3},"title":"MFC \/ C++\ub85c \ud2b9\uc815 \uc0ac\uc774\ud2b8 \uac00\uc838\uc640\uc11c \ubd84\uc11d \ud558\uae30 \uc18c\uc2a4","date":"2014-07-23","format":false,"excerpt":"#include <stdio.h> #include <windows.h> #include <wininet.h> #include <string> #include <comdef.h> #include <mshtml.h> #import <mshtml.tlb> no_auto_exclude #pragma comment(lib, \"wininet.lib\") #include <iostream> #include <fstream> using namespace std; int main(int argc, char* argv[]){ CoInitialize(NULL); ofstream dbfile (\"output.db\"); string sLI; string m_strURL; HINTERNET hOpen, hFile; MSHTML::IHTMLDocument2Ptr pDoc; HRESULT hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER, IID_IHTMLDocument2,\u2026","rel":"","context":"In &quot;C\/C++&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":335,"url":"https:\/\/blog.box.kr\/?p=335","url_meta":{"origin":230,"position":4},"title":"\uc815\uaddc\ud45c\ud604\uc2dd(Regular Expression) on C++","date":"2014-08-11","format":false,"excerpt":"*\u00a0C++ Regex 2011\ub144 \uacbd C++\uc758 \uc0c8\ub85c\uc6b4 \ud45c\uc900 C++11 (C++0x)\uc744 \uc815\uc758\ud558\ub294 \uacfc\uc815\uc5d0\uc11c Boost.Regex\uac00 \ud45c\uc900\uc73c\ub85c \ud3ec\ud568\ub418\uc5c8\ub2e4. C++11\uc758 \uc815\uaddc\ud45c\ud604\uc2dd \ub77c\uc774\ube0c\ub7ec\ub9ac\ub294 <regex> \ud5e4\ub354\uc5d0 \uc815\uc758\ub418\uc5b4 \uc788\ub2e4.\uc774\ub85c \uc778\ud574 \ubcc4\ub3c4\uc758 \ub77c\uc774\ube0c\ub7ec\ub9ac\ub97c \uc124\uce58\ud558\uc9c0 \uc54a\uace0\ub3c4 \uc190\uc27d\uac8c \uc815\uaddc\ud45c\ud604\uc2dd \uae30\ub2a5\uc744 \ud65c\uc6a9\ud560 \uc218 \uc788\uac8c \ub418\uc5c8\ub2e4. \ucd5c\uc2e0 \ubc84\uc804\uc758 Visual C++, GNU C++ \ucef4\ud30c\uc77c\ub7ec\ub294 std::regex\ub97c \ud3ec\ud568\ud55c C++11 \ud45c\uc900\uc774 \uc815\uc758\ud55c \ub300\ubd80\ubd84\uc758 \uae30\ub2a5\uc744 \uc9c0\uc6d0\ud55c\ub2e4. \ucef4\ud30c\uc77c\ub7ec\ubcc4 C++11\u2026","rel":"","context":"In &quot;C\/C++&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":446,"url":"https:\/\/blog.box.kr\/?p=446","url_meta":{"origin":230,"position":5},"title":"[\ud38c]Jeus JMS \ud1b5\uacc4 \uc815\ubcf4 \uc5bb\uae30..","date":"2014-12-18","format":false,"excerpt":"\u2605 Jeus JMS \ud1b5\uacc4 \uc815\ubcf4 \uc5bb\uae30.. - . JMX \uad6c\ub3d9 \ubc29\uc2dd -.\u00a0 JeusJmxUtil.java, QueStatInfo.java\u00a0 \ub450\uac1c \ud30c\uc77c \uad6c\ud604 \u00a0 [1. JeusJmxUtil.java \uc18c\uc2a4..\u00a0 package \uba85\uc740 \uc54c\uc544\uc11c \ubc14\uafd4\uc8fc\ub294 \uc13c\uc2a4..~~] [ main \uba54\uc18c\ub4dc\uc5d0 \uc0d8\ud50c \ucf54\ub4dc \uc791\uc131\ud588\uc74c.] package com.krxapm.util; import java.util.ArrayList; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Set; import javax.management.MBeanServerConnection; import javax.management.MBeanServerInvocationHandler;\u2026","rel":"","context":"In &quot;\uc77c\uc0c1&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/230"}],"collection":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=230"}],"version-history":[{"count":0,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/230\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}