{"id":1156,"date":"2016-08-11T11:19:46","date_gmt":"2016-08-11T02:19:46","guid":{"rendered":"http:\/\/blog.box.kr\/?p=1156"},"modified":"2016-08-11T11:19:46","modified_gmt":"2016-08-11T02:19:46","slug":"c-key-input","status":"publish","type":"post","link":"https:\/\/blog.box.kr\/?p=1156","title":{"rendered":"c++ key input"},"content":{"rendered":"<pre class=\"lang-cpp prettyprint prettyprinted\"><code><span class=\"com\">#include<\/span> <span class=\"str\">&lt;iostream&gt;<\/span>\r\n<span class=\"kwd\">using<\/span><span class=\"pln\"> std<\/span><span class=\"pun\">::<\/span><span class=\"pln\">cout<\/span><span class=\"pun\">;<\/span>\r\n<span class=\"kwd\">using<\/span><span class=\"pln\"> std<\/span><span class=\"pun\">::<\/span><span class=\"pln\">cin<\/span><span class=\"pun\">;<\/span>\r\n\r\n<span class=\"typ\">int<\/span><span class=\"pln\"> main<\/span><span class=\"pun\">()<\/span>\r\n<span class=\"pun\">{<\/span>\r\n  <span class=\"kwd\">char<\/span><span class=\"pln\"> thing<\/span><span class=\"pun\">;<\/span><span class=\"pln\">\r\n\r\n  cin <\/span><span class=\"pun\">&gt;&gt;<\/span><span class=\"pln\"> thing<\/span><span class=\"pun\">;<\/span>\r\n  <span class=\"kwd\">if<\/span> <span class=\"pun\">(<\/span><span class=\"pln\">thing <\/span><span class=\"pun\">==<\/span> <span class=\"str\">'a'<\/span><span class=\"pun\">)<\/span><span class=\"pln\">\r\n    cout <\/span><span class=\"pun\">&lt;&lt;<\/span> <span class=\"str\">\"You pressed 'a'!\\n\"<\/span><span class=\"pun\">;<\/span>\r\n  <span class=\"kwd\">else<\/span><span class=\"pln\">\r\n    cout <\/span><span class=\"pun\">&lt;&lt;<\/span> <span class=\"str\">\"You pressed not-'a': \"<\/span> <span class=\"pun\">&lt;&lt;<\/span><span class=\"pln\"> thing <\/span><span class=\"pun\">&lt;&lt;<\/span> <span class=\"str\">\"\\n\"<\/span><span class=\"pun\">;<\/span>\r\n  <span class=\"kwd\">return<\/span> <span class=\"lit\">0<\/span><span class=\"pun\">;<\/span>\r\n<span class=\"pun\">}<\/span><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#include &lt;iostream&gt; using std::cout; using std::cin; int main() { char thing; cin &gt;&gt; thing; if (thing == &#8216;a&#8217;) cout &lt;&lt; &#8220;You pressed &#8216;a&#8217;!\\n&#8221;; else cout &lt;&lt; &#8220;You pressed not-&#8216;a&#8217;: &#8221; &lt;&lt; thing &lt;&lt; &#8220;\\n&#8221;; return 0; }<\/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":[1],"tags":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5q9Zn-iE","jetpack-related-posts":[{"id":335,"url":"https:\/\/blog.box.kr\/?p=335","url_meta":{"origin":1156,"position":0},"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":178,"url":"https:\/\/blog.box.kr\/?p=178","url_meta":{"origin":1156,"position":1},"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":964,"url":"https:\/\/blog.box.kr\/?p=964","url_meta":{"origin":1156,"position":2},"title":"how to calculate duration time","date":"2015-08-26","format":false,"excerpt":"http:\/\/stackoverflow.com\/questions\/6734375\/c-boost-get-current-time-in-milliseconds \u00a0 int main(int argc, char* argv[]) { boost::posix_time::ptime t1 = boost::posix_time::second_clock::local_time(); boost::this_thread::sleep(boost::posix_time::millisec(500)); boost::posix_time::ptime t2 = boost::posix_time::second_clock::local_time(); boost::posix_time::time_duration diff = t2 - t1; std::cout << diff.total_milliseconds() << std::endl; boost::posix_time::ptime mst1 = boost::posix_time::microsec_clock::local_time(); boost::this_thread::sleep(boost::posix_time::millisec(500)); boost::posix_time::ptime mst2 = boost::posix_time::microsec_clock::local_time(); boost::posix_time::time_duration msdiff = mst2 - mst1; std::cout << msdiff.total_milliseconds() << std::endl; return 0;\u2026","rel":"","context":"In &quot;\uae30\uc220&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":230,"url":"https:\/\/blog.box.kr\/?p=230","url_meta":{"origin":1156,"position":3},"title":"std::string \ub2e4\ub8e8\uae30.. ( \ucc3e\uae30, \uacf5\ubc31\uc81c\uac70 \ub4f1\ub4f1)","date":"2014-07-23","format":false,"excerpt":"\ubb38\uc790\uc5f4 string #include \"StdAfx.h\" #include \"StringTest.h\" #include <algorithm> \/\/transform \uc0ac\uc6a9 #include <functional> \/\/bind1st using std::string; \/\/ \uc774\ub807\uac8c \uc9c0\uc815\ud574\uc900\ub2e4. StringTest::StringTest() { log(\"StringTest \uc0dd\uc131\uc790 \ud638\ucd9c\"); } StringTest::~StringTest(void) { log(\"StringTest \uc18c\uba78\uc790 \ud638\ucd9c\"); } void StringTest::test() { log(\"============ string class ==========\"); \/\/ \uc0dd\uc131\uc790 \u00a0 std::string s0; \/\/ \ube44\uc5b4\uc788\ub294 string std::string s1(\"012345\",3); \/\/ \uacb0\uacfc: 012\u2026","rel":"","context":"In &quot;C\/C++&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":337,"url":"https:\/\/blog.box.kr\/?p=337","url_meta":{"origin":1156,"position":4},"title":"\uc815\uaddc\uc2dd \uc0ac\uc6a9\ubc95 [\ud38c] boost \uc0ac\uc6a9","date":"2014-08-12","format":false,"excerpt":"\uc9c8\ubb38 ::#\uc774 \ubd99\uc740 \uc804\ud654 \ubc88\ud638 \uc55e\uc5d0\ub294 %23\uc744 \ubd99\uc774\uace0 \uc2f6\uc74c.. \u00a0 \ub2f5\ucf54\ub4dc :: std::string result, list = \"#011-222-3333\"; const char* regStr = \"(#)?(01[016789])-?(d{3,4})-?(d{4})\"; const char* subStr = \"(?1%23)$2$3$4\"; boost::regex_replace(result, list.begin(), list.end(), regStr, subStr, boost::match_default | boost::format_all); std::cout << result << std::endl; [url]http:\/\/www.boost.org\/libs\/regex\/doc\/regex_replace.html[\/url] [url]http:\/\/ourworld.compuserve.com\/homepages\/John_Maddock\/[\/url] [url]http:\/\/research.microsoft.com\/projects\/greta\/gretauserguide.htm[\/url] \u00a0","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":1156,"position":5},"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":[]}],"_links":{"self":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/1156"}],"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=1156"}],"version-history":[{"count":1,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/1156\/revisions"}],"predecessor-version":[{"id":1157,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/1156\/revisions\/1157"}],"wp:attachment":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}