{"id":2575,"date":"2020-03-21T18:28:54","date_gmt":"2020-03-21T18:28:54","guid":{"rendered":"https:\/\/itteacheritfreelance.hk\/wordpress\/?p=2575"},"modified":"2020-04-23T15:32:05","modified_gmt":"2020-04-23T15:32:05","slug":"cmachine-input-and-output","status":"publish","type":"post","link":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/2020\/03\/21\/cmachine-input-and-output\/","title":{"rendered":"C++ machine input and output"},"content":{"rendered":"\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/itteacheritfreelance.hk\/test\/wordpress\/wp-content\/uploads\/2016\/04\/c-c-programming-for-hackers-part-1-introduction.1280x600.jpg\" alt=\"C++ ,C\u8bed\u8a00, \u96fb\u8166\u73ed, C\u7a0b\u5e8f\u8bbe\u8ba1\u8bed\u8a00, C\/C++\u96fb\u8166\u73ed, \u96fb\u8166\u8ab2\u7a0b, \u96fb\u8166\u8ab2\u7a0b, C++\u88dc\u7fd2\u6559\u5b78, C++\u88dc\u7fd2,C++\u7a0b\u5f0f\u7de8\u5beb,C++\u8ab2\u7a0b\u88dc\u7fd2,C++, \u5927\u5b78\u751fC++\u8ab2\u7a0b ,C++1 \u5c0d 1 \u79c1\u4eba\u96fb\u8166\u8ab2\u7a0b, C++1 \u5c0d 1 \u79c1\u4eba\u96fb\u8166\u88dc\u7fd2,C++\u79c1\u4eba\u88dc\u7fd2, C++\u96fb\u8166\u8208\u8da3\u73ed, C++\u96fb\u8166\u88dc\u7fd2\u73ed\" class=\"wp-image-175\"\/><figcaption>C\/C++<\/figcaption><\/figure>\n\n\n\n<p>\n\n\u5b78\u7fd2C++\u7684\u904e\u7a0b\u4e2d\uff0c\u901a\u5e38\u662f\u7531\u7d42\u7aef\u6a5f\uff0c\u4e5f\u5c31\u662f\u6587\u5b57\u6a21\u5f0f\u4e0b\u958b\u59cb\uff0c\u70ba\u4e86\u8207\u7a0b\u5f0f\u4e92\u52d5\uff0c\u5728\u7d42\u7aef\u6a5f\u4e0b\u8f38\u51fa\u7a0b\u5f0f\u57f7\u884c\u7d50\u679c\uff0c\u6216\u662f\u5f9e\u7d42\u7aef\u6a5f\u53d6\u5f97\u4f7f\u7528\u8005\u7684\u8f38\u5165\u8cc7\u6599\u662f\u57fa\u672c\u9700 \u6c42\uff0c\u5728C++\u4e2d\u8f38\u5165\u8f38\u51fa\u662f\u7531\u6a19\u6e96library\u4e2d\u7684iostream library\u63d0\u4f9b\uff0c\u9019\u4e5f\u5c31\u662f\u70ba\u4f55\u60a8\u8981\u5728\u7a0b\u5f0f\u7684\u4e00\u958b\u982d\u7d42\u662f\u52a0\u4e0a\uff1a<br><strong>#include &lt;iostream&gt;&nbsp;<\/strong><\/p>\n\n\n\n<p>\u5c07\u8a0a\u606f\u8f38\u51fa\u81f3\u7d42\u7aef\u6a5f\uff0c\u7a31\u4e4b\u70ba\u300c\u6a19\u6e96\u8f38\u51fa\u300d\uff08Stand output\uff09\uff0cC++\u85c9\u7531iostream\u7269\u4ef6cout\uff08\u767c\u97f3see-out\uff09\u5c07\u8a0a\u606f\u8f38\u51fa\u81f3\u7d42\u7aef\u6a5f\uff0c&lt; &lt;\u904b\u7b97\u5b50\u5c07\u4e00\u500b\u6307\u5b9a\u7684\u8a0a\u606f\u6216\u6578\u503c\u6307\u5f15\u81f3\u6a19\u6e96\u8f38\u51fa\u7269\u4ef6\u4e0a\uff0c\u4f8b\u5982\u986f\u793a&#8221;Hello! World!&#8221;\u8a0a\u606f\u6642\uff0c\u60a8\u53ef\u4ee5\u9019\u9ebc\u64b0\u5beb\uff1a<br><strong>cout &lt;&lt; &#8220;Hello! World!&#8221;;<\/strong><\/p>\n\n\n\n<p>\u6a19\u6e96\u8f38\u51fa\u53ef\u4ee5\u88ab\u91cd\u65b0\u5c0e\u5411\u81f3\u4e00\u500b\u6a94\u6848\uff0c\u60a8\u53ef\u4ee5\u5728\u57f7\u884c\u7a0b\u5f0f\u6642\u4f7f\u7528&#8221; &gt;&gt;&#8221;\u5c07\u8f38\u51fa\u7d50\u679c\u5c0e\u5411\u81f3\u6307\u5b9a\u7684\u6a94\u6848\uff0c\u4f8b\u5982\uff08\u5047\u8a2d\u7de8\u8b6f\u5f8c\u7684\u53ef\u57f7\u884c\u6a94\u70bamain\uff09\uff1a<br><strong>main &gt;&gt; result.txt<\/strong><\/p>\n\n\n\n<p>\u5982\u679c\u7a0b\u5f0f\u7684\u76ee\u7684\u662f\u986f\u793a&#8221;Hello! World!&#8221;\uff0c\u5247\u4e0a\u9762\u7684\u57f7\u884c\u6703\u5c07\u7d50\u679c\u5c0e\u5411\u81f3result.txt\uff0c\u800c\u4e0d\u6703\u5728\u87a2\u5e55\u4e0a\u986f\u793a&#8221;Hello! World!&#8221;\uff0cresult.txt\u4e2d\u5c07\u6703\u6709\u8f38\u51fa\u7d50\u679cHello! World!\u3002&nbsp;<\/p>\n\n\n\n<p>\u60a8\u4e5f\u53ef\u4ee5\u4f7f\u7528iostream\u7269\u4ef6cerr\uff08\u767c\u97f3see-err\uff09\uff0c\u7a31\u4e4b\u70ba\u300c\u6a19\u6e96\u932f\u8aa4\u300d\uff08Standard error\uff09\uff0c\u5b83\u6703\u5c07\u8a0a\u606f\u8f38\u51fa\u81f3\u7d42\u7aef\u6a5f\u4e0a\uff0c\u8207\u6a19\u6e96\u8f38\u51fa\u4e0d\u540c\u7684\u662f\uff0ccerr\u6703 \u7acb\u5373\u986f\u793a\u6307\u5b9a\u7684\uff08\u932f\u8aa4\uff09\u8a0a\u606f\u7d66\u4f7f\u7528\u8005\u77e5\u9053\uff0c\u5373\u4f7f\u60a8\u6307\u5b9a\u7a0b\u5f0f\u5c07\u7d50\u679c\u91cd\u65b0\u5c0e\u5411\u81f3\u6a94\u6848\uff0ccerr\u8f38\u51fa\u4e32\u6d41\u7684\u8a0a\u606f\u4e26\u4e0d\u6703\u88ab\u91cd\u65b0\u5c0e\u5411\uff0c\u800c\u4ecd\u6703\u986f\u793a\u5728\u6307\u5b9a\u7684\u986f\u793a\u88dd\u7f6e \u4e0a\uff0c\u4e0b\u9762\u9019\u500b\u4f8b\u5b50\u7d66\u60a8\u4e00\u500b\u7c21\u55ae\u7684\u6e2c\u8a66\u65b9\u5f0f \uff1a<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream> using namespace std; int main() {      cout &lt;&lt; \"Hello! World!\" &lt;&lt; endl;    cerr &lt;&lt; \"Sorry! World!\" &lt;&lt; endl;     return 0;}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"> C++ \u7d42\u7aef\u6a5f \u7d50\u679c <\/h2>\n\n\n\n<p>\u5728\u7de8\u8b6f\u7a0b\u5f0f\u4e4b\u5f8c\uff0c\u8acb\u5982\u4e0b\u57f7\u884c\u7a0b\u5f0f\uff0c\u60a8\u6703\u767c\u73fe\u8f38\u51fa\u7d50\u679c\u5982\u4e0b\uff1a<br>main &gt;&gt; result.txt<br>Sorry! World!<br>\u958b\u555fresult.txt\u4e4b\u5f8c\uff0c\u60a8\u6703\u767c\u73fe\u7576\u4e2d\u53ea\u6709Hello! World!\u8a0a\u606f\uff0c\u800cSorry! World!\u8a0a\u606f\u4e26\u6c92\u6709\u88ab\u5c0e\u5411\u81f3\u6a94\u6848\u4e2d\uff0c\u800c\u662f\u76f4\u63a5\u986f\u793a\u5728\u7d42\u7aef\u6a5f\u4e2d\u3002&nbsp;<\/p>\n\n\n\n<p>\u8981 \u91cd\u65b0\u5c0e\u5411 standard output \u662f\u7528 &#8216;&gt;&#8217;, standard input \u5247\u662f &#8220;&lt;&#8220;\uff0c\u800c&#8221;&gt;&gt;&#8221; \u9664\u4e86\u91cd\u5c0e standard output \u5f8c\uff0c\u9084\u6709\u9644\u52a0\u7684\u529f\u80fd\uff0c\u4e5f\u5c31\u662f\u6703\u628a\u8f38\u51fa\u9644\u52a0\u5230\u88ab\u5c0e\u5411\u7684\u76ee\u6a19\u6a94\u6848\u5f8c\u982d\uff0c\u5982\u679c\u76ee\u6a19\u6a94\u6848\u672c\u4f86\u4e0d\u5b58\u5728\uff0c\u90a3\u9ebc\u6548\u679c\u5c31\u548c&#8221;&gt;&#8221;\u4e00\u6a23\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u6253\u7b97\u53d6\u5f97\u4f7f\u7528\u8005\u7684\u8f38\u5165\uff0c\u5247\u53ef\u4ee5\u4f7f\u7528\u300c\u6a19\u6e96\u8f38\u5165\u300d\uff08Standard input\uff09\u7684iostream\u7269\u4ef6cin\uff08\u767c\u97f3see-in\uff09\uff0c\u4e26\u4f7f\u7528&gt;&gt;\u904b\u7b97\u5b50\u5c07\u8f38\u5165\u7684\u8a0a\u606f\u6307\u5b9a\u7d66\u8b8a\u6578\uff0c\u4f8b\u5982\uff1a&nbsp;<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream> using namespace std; int main() {     int number = int();    cout &lt;&lt; \"\u8acb\u8f38\u5165\u6578\u5b57: \";     cin >> number;    cout &lt;&lt; \"\u8f38\u5165\u7684\u6578\u5b57: \" &lt;&lt; number &lt;&lt; endl;     return 0;}<\/code><\/pre>\n\n\n\n<p>\u57f7\u884c\u7d50\u679c\uff1a<br>\u8acb\u8f38\u5165\u6578\u5b57: 10<br>\u8f38\u5165\u7684\u6578\u5b57: 10\n\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/itteacheritfreelance.hk\/test\/wordpress\/wp-content\/uploads\/2016\/03\/2014032it-1024x631.jpg\" alt=\"IT\u96fb\u8166\u88dc\u7fd2, IT Teacher IT Freelance\" class=\"wp-image-8\"\/><\/figure>\n\n\n<p><!--EndFragment--><\/p>","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>\u5b78\u7fd2C++\u7684\u904e\u7a0b\u4e2d\uff0c\u901a\u5e38\u662f\u7531\u7d42\u7aef\u6a5f\uff0c\u4e5f\u5c31\u662f\u6587\u5b57\u6a21\u5f0f <a class=\"mh-excerpt-more\" href=\"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/2020\/03\/21\/cmachine-input-and-output\/\" title=\"C++ machine input and output\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":36,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"C++ machine input and output - ITTeacherITFreelance.hk","description":"\u5b78\u7fd2C++\u7684\u904e\u7a0b\u4e2d\uff0c\u901a\u5e38\u662f\u7531\u7d42\u7aef\u6a5f\uff0c\u4e5f\u5c31\u662f\u6587\u5b57\u6a21\u5f0f\u4e0b\u958b\u59cb\uff0c\u70ba\u4e86\u8207\u7a0b\u5f0f\u4e92\u52d5\uff0c\u5728\u7d42\u7aef\u6a5f\u4e0b\u8f38\u51fa\u7a0b\u5f0f\u57f7\u884c\u7d50\u679c\uff0c\u6216\u662f\u5f9e\u7d42\u7aef\u6a5f\u53d6\u5f97\u4f7f\u7528\u8005\u7684\u8f38\u5165\u8cc7\u6599\u662f\u57fa\u672c\u9700 \u6c42\uff0c\u5728C++\u4e2d\u8f38\u5165\u8f38\u51fa\u662f\u7531\u6a19\u6e96library\u4e2d\u7684iostream library\u63d0\u4f9b\uff0c\u9019\u4e5f\u5c31\u662f\u70ba\u4f55\u60a8\u8981\u5728\u7a0b\u5f0f\u7684\u4e00\u958b\u982d\u7d42\u662f\u52a0\u4e0a\uff1a #include &lt;iostream&gt"},"footnotes":""},"categories":[1306],"tags":[],"_links":{"self":[{"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/2575"}],"collection":[{"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=2575"}],"version-history":[{"count":3,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/2575\/revisions"}],"predecessor-version":[{"id":12859,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/2575\/revisions\/12859"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/media\/36"}],"wp:attachment":[{"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=2575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=2575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=2575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}