{"id":115377,"date":"2026-10-12T02:17:20","date_gmt":"2026-10-11T18:17:20","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/115377.html"},"modified":"2026-10-12T02:17:20","modified_gmt":"2026-10-11T18:17:20","slug":"linux%e7%b3%bb%e5%88%97%ef%bc%8805%ef%bc%89-%e5%9f%ba%e7%a1%80%e5%bc%80%e5%8f%91%e5%b7%a5%e5%85%b7%ef%bc%88%e4%b8%8b%ef%bc%89makefile%e3%80%81git%e3%80%81gdb","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/115377.html","title":{"rendered":"Linux\u7cfb\u5217\uff0805\uff09\u2014\u2014\u57fa\u7840\u5f00\u53d1\u5de5\u5177\uff08\u4e0b\uff09makefile\u3001git\u3001gdb"},"content":{"rendered":"<p> <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261011181714-6acbd2aaa47fd.png\" \/> <\/p>\n<p><b> \u2b50\ufe0f\u535a\u4e3b&#xff1a; <font color=\"#ff\"><b> \u6b64\u751f\u51b3int-&#064;CSDN\u535a\u5ba2<\/b><\/font> <\/b><\/p>\n<p>  <font color=\"#ff4d4f\"><b>\u2003\u901f\u80dc\u6d3e\u5c31\u662f\u6700\u5927\u7684\u6295\u964d\u6d3e&#xff01;&#xff01;&#xff01;<\/b><\/font> <\/p>\n<p>\u2003\u2003\u2003\u2003\u2003\u2003\u2003\u2003\u2003&#x1f525;\u70ed\u95e8\u4e13\u680f&#x1f525;<\/p>\n<p>\u2003\u2003\u2003\u2003\u2003\u2003\u6df1\u5165\u7406\u89e3 C&#043;&#043; \u7cfb\u5217 &#xff5c; \u7b97\u6cd5\u7cfb\u5217<\/p>\n<p>\u2003\u2003\u2003\u2003\u2003\u2003\u5feb\u901f\u590d\u4e60\u7cfb\u5217 &#xff5c; Linux\u7cfb\u5217<\/p>\n<p>Gitee\u5730\u5740&#xff1a;\u8d22\u54e5 | GitHub\u5730\u5740&#xff1a;\u8d22\u54e5<\/p>\n<hr \/>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>\n<ul>\n<li>\u4e0a\u671f\u56de\u987e<\/li>\n<li>4. \u81ea\u52a8\u5316\u6784\u5efa&#xff1a;&#096;make&#096; \/ &#096;Makefile&#096;\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f<\/li>\n<li>\n<ul>\n<li>4-1 \u80cc\u666f<\/li>\n<li>\n<ul>\n<li>\u624b\u52a8\u7f16\u8bd1\u9047\u5230\u7684\u95ee\u9898<\/li>\n<li>&#096;make&#096; \u548c &#096;Makefile&#096; \u7684\u533a\u522b<\/li>\n<\/ul>\n<\/li>\n<li>4-2 \u7406\u89e3<\/li>\n<li>\n<ul>\n<li>\u4f9d\u8d56\u5173\u7cfb\u548c\u4f9d\u8d56\u65b9\u6cd5<\/li>\n<\/ul>\n<\/li>\n<li>4-3 \u57fa\u672c\u4f7f\u7528<\/li>\n<li>\n<ul>\n<li>\u4e00\u4e2a\u5b8c\u6574\u7684 &#096;Makefile&#096;<\/li>\n<li>\u89c4\u5219\u7684\u4e66\u5199\u683c\u5f0f<\/li>\n<li>\n<ul>\n<li>\u8bed\u6cd5<\/li>\n<li>\u529f\u80fd<\/li>\n<li>\u793a\u4f8b<\/li>\n<li>\u6ce8\u610f\u4e8b\u9879<\/li>\n<\/ul>\n<\/li>\n<li>\u4f7f\u7528 &#096;make&#096;<\/li>\n<li>\n<ul>\n<li>\u8bed\u6cd5<\/li>\n<li>\u529f\u80fd<\/li>\n<li>\u793a\u4f8b<\/li>\n<li>\u6ce8\u610f\u4e8b\u9879<\/li>\n<\/ul>\n<\/li>\n<li>&#096;.PHONY&#096; \u548c\u4f2a\u76ee\u6807<\/li>\n<li>\n<ul>\n<li>\u8bed\u6cd5<\/li>\n<li>\u529f\u80fd<\/li>\n<li>\u6ce8\u610f\u4e8b\u9879<\/li>\n<\/ul>\n<\/li>\n<li>\u4e3a\u4ec0\u4e48\u4e0d\u4f1a\u91cd\u590d\u7f16\u8bd1<\/li>\n<li>\n<ul>\n<li>\u6587\u4ef6\u7684\u65f6\u95f4\u5c5e\u6027<\/li>\n<li>\u5224\u65ad\u89c4\u5219<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>4-4 \u63a8\u5bfc\u8fc7\u7a0b<\/li>\n<li>\n<ul>\n<li>\u50cf\u6808\u4e00\u6837\u6267\u884c<\/li>\n<li>&#096;make&#096; \u7684\u5de5\u4f5c\u65b9\u5f0f<\/li>\n<li>&#096;make&#096; \u4e0d\u68c0\u67e5\u547d\u4ee4\u662f\u5426\u6b63\u786e<\/li>\n<\/ul>\n<\/li>\n<li>4-5 \u9002\u5ea6\u6269\u5c55\u8bed\u6cd5<\/li>\n<li>\n<ul>\n<li>\u53d8\u91cf<\/li>\n<li>\n<ul>\n<li>\u8bed\u6cd5<\/li>\n<li>\u793a\u4f8b<\/li>\n<\/ul>\n<\/li>\n<li>\u81ea\u52a8\u53d8\u91cf<\/li>\n<li>\n<ul>\n<li>\u793a\u4f8b<\/li>\n<\/ul>\n<\/li>\n<li>\u6a21\u5f0f\u5339\u914d<\/li>\n<li>\n<ul>\n<li>\u8bed\u6cd5<\/li>\n<li>\u529f\u80fd<\/li>\n<li>\u793a\u4f8b<\/li>\n<\/ul>\n<\/li>\n<li>&#096;&#064;&#096;&#xff1a;\u4e0d\u56de\u663e\u547d\u4ee4<\/li>\n<li>\n<ul>\n<li>\u8bed\u6cd5<\/li>\n<li>\u529f\u80fd<\/li>\n<li>\u6ce8\u610f\u4e8b\u9879<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>4&#xff0c;\u603b\u7ed3<\/li>\n<li>\n<ul>\n<li>\u4e00\u4e2a\u5c0f\u800c\u7f8e\u7684Makefile\u6587\u4ef6\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f<\/li>\n<\/ul>\n<\/li>\n<li>\u6838\u5fc3\u6982\u5ff5\u3010\u91cd\u70b9\u3011<\/li>\n<li>\u89c4\u5219\u683c\u5f0f\u4e0e\u4f7f\u7528<\/li>\n<li>\u4e0d\u91cd\u590d\u7f16\u8bd1\u539f\u7406\u3010\u91cd\u70b9\u3011\u3010\u6613\u5fd8\u3011<\/li>\n<li>\u53d8\u91cf\u4e0e\u81ea\u52a8\u53d8\u91cf<\/li>\n<\/ul>\n<\/li>\n<li>5. Linux \u7b2c\u4e00\u4e2a\u7cfb\u7edf\u7a0b\u5e8f\u2014\u2014\u8fdb\u5ea6\u6761<\/li>\n<li>\n<ul>\n<li>5-1 \u8865\u5145&#xff1a;\u56de\u8f66\u4e0e\u6362\u884c<\/li>\n<li>5-2 \u884c\u7f13\u51b2\u533a<\/li>\n<li>\n<ul>\n<li>5-2-1 \u4e3a\u4ec0\u4e48\u8c03\u7528 &#096;printf&#096; \u540e\u4e0d\u4e00\u5b9a\u9a6c\u4e0a\u770b\u89c1\u6587\u5b57<\/li>\n<li>5-2-2 \u4ec0\u4e48\u662f\u884c\u7f13\u51b2<\/li>\n<li>\n<ul>\n<li>\u6ce8\u610f\u4e8b\u9879<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>5-4 \u8fdb\u5ea6\u6761\u4ee3\u7801<\/li>\n<li>\n<ul>\n<li>5-4-1 \u8fdb\u5ea6\u6761\u7684\u663e\u793a\u7ed3\u6784<\/li>\n<li>5-4-2 version1&#xff1a;\u56fa\u5b9a 101 \u683c\u7684\u539f\u7406\u7248\u672c<\/li>\n<li>\n<ul>\n<li>\u89e3\u51b3\u7684\u95ee\u9898<\/li>\n<li>\u5b8c\u6574\u4ee3\u7801<\/li>\n<\/ul>\n<\/li>\n<li>5-4-3 version2&#xff1a;\u6839\u636e\u771f\u5b9e\u8fdb\u5ea6\u66f4\u65b0<\/li>\n<li>\n<ul>\n<li>\u4e3a\u4ec0\u4e48\u9700\u8981\u771f\u5b9e\u8fdb\u5ea6<\/li>\n<li>\u5b8c\u6574\u4ee3\u7801<\/li>\n<\/ul>\n<\/li>\n<li>5-4-4 \u914d\u5957 Makefile&#xff1a;\u81ea\u52a8\u5316\u6784\u5efa\u591a\u4e2a\u6e90\u6587\u4ef6<\/li>\n<li>\n<ul>\n<li>\u5b8c\u6574 Makefile<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u603b\u7ed3&#xff1a;5. \u7b2c\u4e00\u4e2a\u7cfb\u7edf\u7a0b\u5e8f&#xff1a;\u8fdb\u5ea6\u6761<\/li>\n<li>\n<ul>\n<li>\u56de\u8f66 vs \u6362\u884c\u3010\u6613\u6df7\u3011\u3010\u91cd\u70b9\u3011<\/li>\n<li>\u884c\u7f13\u51b2\u533a\u3010\u91cd\u70b9\u3011<\/li>\n<li>\u52a8\u6001\u663e\u793a\u6838\u5fc3\u7ec4\u5408\u3010\u91cd\u70b9\u3011<\/li>\n<li>\u8fdb\u5ea6\u6761\u5b9e\u73b0\u8981\u70b9<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>6. \u7248\u672c\u63a7\u5236\u5668 Git<\/li>\n<li>\n<ul>\n<li>\n<ul>\n<li>Git\u3001\u672c\u5730\u4ed3\u5e93\u548c\u8fdc\u7aef\u4ed3\u5e93<\/li>\n<\/ul>\n<\/li>\n<li>6-2 Git \u7b80\u53f2<\/li>\n<li>6-3 \u5b89\u88c5 Git<\/li>\n<li>6-4 \u5728 GitHub \u521b\u5efa\u9879\u76ee<\/li>\n<li>\n<ul>\n<li>\u521b\u5efa\u8fdc\u7aef\u4ed3\u5e93<\/li>\n<li>\u4f7f\u7528 &#096;git clone&#096; \u4e0b\u8f7d\u9879\u76ee<\/li>\n<\/ul>\n<\/li>\n<li>6-5 Git \u4e09\u677f\u65a7<\/li>\n<li>\n<ul>\n<li>\u9996\u6b21\u4f7f\u7528\u914d\u7f6e\u7528\u6237\u540d\u548c\u90ae\u7bb1<\/li>\n<li>\u7248\u672c\u7ba1\u7406\u53ea\u7ba1\u7406\u6e90\u6587\u4ef6<\/li>\n<li>\u4f7f\u7528 &#096;.gitignore&#096; \u5ffd\u7565\u6587\u4ef6<\/li>\n<li>&#096;git push&#096; \u88ab\u62d2\u7edd\u65f6\u7684\u51b2\u7a81<\/li>\n<li>\u5176\u4ed6\u5e38\u7528\u547d\u4ee4<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u603b\u7ed3&#xff1a;6. \u7248\u672c\u63a7\u5236\u5668 Git<\/li>\n<li>\n<ul>\n<li>\u6838\u5fc3\u6982\u5ff5<\/li>\n<li>\u4e09\u677f\u65a7\u3010\u91cd\u70b9\u3011<\/li>\n<li>\u8f85\u52a9\u547d\u4ee4\u4e0e .gitignore<\/li>\n<\/ul>\n<\/li>\n<li>7. \u8c03\u8bd5\u5668 gdb\/cgdb<\/li>\n<li>\n<ul>\n<li>cgdb<\/li>\n<li>\u9884\u5907&#xff1a;\u5fc5\u987b\u5148 -g\u3010\u91cd\u70b9\u3011<\/li>\n<li>gdb\u547d\u4ee4\u5408\u96c6\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f<\/li>\n<li>\u5e38\u7528\u547d\u4ee4\u901f\u67e5<\/li>\n<li>\u4e09\u4e2a\u8c03\u8bd5\u6280\u5de7\u3010\u91cd\u70b9\u3011<\/li>\n<\/ul>\n<\/li>\n<li>8. \u9644\u5f55&#xff1a;\u6362\u6e90\u5b9e\u64cd<\/li>\n<li>\n<ul>\n<li>\u6b65\u9aa4\u4e3b\u7ebf&#xff08;\u4e24\u8005\u4e00\u81f4&#xff09;<\/li>\n<li>CentOS 7 \u6362 yum \u6e90<\/li>\n<li>Ubuntu \u6362 apt \u6e90<\/li>\n<\/ul>\n<\/li>\n<li>\u6613\u6df7\u6dc6\u5bf9\u6bd4\u901f\u67e5\u5361<\/li>\n<li>\u4e0b\u671f\u9884\u544a<\/li>\n<li>\u7ebf\u7a0b<\/li>\n<li>\u7ed3\u8bed<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>\u4e0a\u671f\u56de\u987e<\/h3>\n<p>\u2003\u2003\u5927\u5bb6\u597d&#xff0c;\u8fd9\u91cc\u662f\u6b64\u751f\u5f03int&#xff08;\u8d22\u54e5&#xff09;&#xff0c;\u6b22\u8fce\u6765\u5230\u6211\u7684\u535a\u5ba2\u3002\u4e0a\u4e00\u7bc7\u6211\u4eec\u4e3b\u8981\u5b66\u4e60\u4e86\u57fa\u7840\u5f00\u53d1\u5de5\u5177\u7684\u524d\u534a\u90e8\u5206&#xff0c;\u5b66\u4e60\u548c\u8ba4\u8bc6\u4e86\u8f6f\u4ef6\u5305\u7ba1\u7406\u5668\u3001vim\u3001gcc\/g&#043;&#043;&#xff0c;\u90a3\u4e48\u4eca\u5929\u6211\u4eec\u7ee7\u7eed\u6765\u5b66\u4e60\u5269\u4e0b\u7684\u51e0\u4e2a\u5f00\u53d1\u5de5\u5177&#xff1a;\u8f6f\u4ef6\u5305\u7ba1\u7406\u5668\u3001vim\u3001gcc\/g&#043;&#043;&#xff0c;\u90a3\u6211\u4eec\u5f00\u59cb\u5427&#xff01;<\/p>\n<h3>4. \u81ea\u52a8\u5316\u6784\u5efa&#xff1a;make \/ Makefile\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f<\/h3>\n<h4>4-1 \u80cc\u666f<\/h4>\n<h5>\u624b\u52a8\u7f16\u8bd1\u9047\u5230\u7684\u95ee\u9898<\/h5>\n<p>\u5c0f\u7a0b\u5e8f\u53ea\u6709\u4e00\u4e2a\u6e90\u6587\u4ef6\u65f6&#xff0c;\u53ef\u4ee5\u624b\u52a8\u6267\u884c&#xff1a;<\/p>\n<p>gcc <span class=\"token parameter variable\">-o<\/span> myproc myproc.c<\/p>\n<p>gcc \u662f\u7f16\u8bd1\u5668&#xff1a;\u628a\u4eba\u5199\u7684\u6e90\u4ee3\u7801\u8f6c\u6362\u6210\u8ba1\u7b97\u673a\u53ef\u4ee5\u8fd0\u884c\u7684\u7a0b\u5e8f\u3002<\/p>\n<p>\u4f46\u5927\u578b\u5de5\u7a0b\u53ef\u80fd\u6709\u6210\u5343\u4e0a\u4e07\u4e2a\u6e90\u6587\u4ef6\u3002\u6bcf\u6b21\u4fee\u6539\u4e00\u4e2a\u6587\u4ef6\u540e&#xff0c;\u5982\u679c\u90fd\u624b\u52a8\u8f93\u5165\u7f16\u8bd1\u547d\u4ee4&#xff0c;\u5c31\u4f1a\u9047\u5230\u4e24\u4e2a\u95ee\u9898&#xff1a;<\/p>\n<li>\u9700\u8981\u8bb0\u4f4f\u5927\u91cf\u7f16\u8bd1\u547d\u4ee4&#xff1b;<\/li>\n<li>\u6ca1\u4fee\u6539\u7684\u6587\u4ef6\u4e5f\u53ef\u80fd\u88ab\u91cd\u590d\u7f16\u8bd1&#xff0c;\u6d6a\u8d39\u65f6\u95f4\u3002<\/li>\n<p>\u56e0\u6b64&#xff0c;\u9700\u8981\u4e00\u4e2a\u6587\u4ef6\u5148\u8bb0\u5f55\u201c\u54ea\u4e9b\u6587\u4ef6\u4f9d\u8d56\u54ea\u4e9b\u6587\u4ef6\u201d\u4ee5\u53ca\u201c\u5982\u4f55\u751f\u6210\u5b83\u4eec\u201d&#xff0c;\u518d\u7528\u4e00\u4e2a\u547d\u4ee4\u81ea\u52a8\u5b8c\u6210\u7f16\u8bd1\u3002<\/p>\n<h5>make \u548c Makefile \u7684\u533a\u522b<\/h5>\n<ul>\n<li>make&#xff1a;\u4e00\u4e2a\u547d\u4ee4&#xff0c;\u8d1f\u8d23\u8bfb\u53d6\u89c4\u5219\u5e76\u6267\u884c\u7f16\u8bd1\u3002<\/li>\n<li>Makefile&#xff1a;\u4e00\u4e2a\u6587\u4ef6&#xff0c;\u8d1f\u8d23\u4fdd\u5b58\u7f16\u8bd1\u89c4\u5219\u3002<\/li>\n<\/ul>\n<p>make \u662f\u547d\u4ee4&#xff0c;Makefile \u662f\u6587\u4ef6&#xff1b;\u4e24\u8005\u642d\u914d\u5b8c\u6210\u81ea\u52a8\u5316\u6784\u5efa\u3002<\/p>\n<hr \/>\n<h4>4-2 \u7406\u89e3<\/h4>\n<h5>\u4f9d\u8d56\u5173\u7cfb\u548c\u4f9d\u8d56\u65b9\u6cd5<\/h5>\n<p>\u5047\u8bbe\u8981\u751f\u6210\u4e00\u4e2a\u7a0b\u5e8f myproc&#xff0c;\u5b83\u9700\u8981\u6e90\u6587\u4ef6 myproc.c\u3002\u5982\u679c\u6ca1\u6709 myproc.c&#xff0c;\u5c31\u65e0\u6cd5\u751f\u6210 myproc&#xff0c;\u8fd9\u5c31\u662f\u4f9d\u8d56\u5173\u7cfb&#xff1a;\u4e00\u4e2a\u6587\u4ef6\u7684\u751f\u6210\u9700\u8981\u53e6\u4e00\u4e2a\u6587\u4ef6\u3002<\/p>\n<p>\u4f46\u662f&#xff0c;\u4ec5\u4ec5\u77e5\u9053\u4f9d\u8d56\u8c01\u8fd8\u4e0d\u591f&#xff0c;\u8fd8\u9700\u8981\u77e5\u9053\u5982\u4f55\u6839\u636e myproc.c \u751f\u6210 myproc&#xff0c;\u8fd9\u5c31\u662f\u4f9d\u8d56\u65b9\u6cd5&#xff1a;\u751f\u6210\u76ee\u6807\u65f6\u8981\u6267\u884c\u7684\u547d\u4ee4\u3002<\/p>\n<p>\u56e0\u6b64&#xff0c;\u4e00\u6761\u89c4\u5219\u53ef\u4ee5\u7406\u89e3\u4e3a&#xff1a;<\/p>\n<p>\u76ee\u6807\u6587\u4ef6  \u2190  \u4f9d\u8d56\u6587\u4ef6<br \/>\n\u751f\u6210\u76ee\u6807\u6587\u4ef6\u7684\u65b9\u6cd5<\/p>\n<p>Makefile \u4e2d\u7684\u57fa\u672c\u5f62\u5f0f\u662f&#xff1a;<\/p>\n<p>\u76ee\u6807:\u4f9d\u8d56<br \/>\n\u751f\u6210\u76ee\u6807\u7684\u547d\u4ee4<\/p>\n<p>\u5176\u4e2d&#xff1a;<\/p>\n<ul>\n<li>\u76ee\u6807&#xff1a;\u60f3\u751f\u6210\u6216\u64cd\u4f5c\u7684\u6587\u4ef6&#xff1b;<\/li>\n<li>\u4f9d\u8d56&#xff1a;\u751f\u6210\u76ee\u6807\u6240\u9700\u8981\u7684\u6587\u4ef6&#xff1b;<\/li>\n<li>\u547d\u4ee4&#xff1a;\u751f\u6210\u76ee\u6807\u65f6\u6267\u884c\u7684\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<p>\u4f9d\u8d56\u5173\u7cfb\u51b3\u5b9a\u201c\u5148\u627e\u8c01\u201d&#xff0c;\u4f9d\u8d56\u65b9\u6cd5\u51b3\u5b9a\u201c\u627e\u5230\u540e\u505a\u4ec0\u4e48\u201d\u3002<\/p>\n<p>\u6838\u5fc3\u6982\u5ff5\u53ea\u6709\u4e24\u4e2a&#xff1a;\u4f9d\u8d56\u5173\u7cfb &#043; \u4f9d\u8d56\u65b9\u6cd5\u3002\u5148\u6709\u4f9d\u8d56\u5173\u7cfb&#xff0c;\u624d\u6709\u6267\u884c\u4f9d\u8d56\u65b9\u6cd5\u7684\u4f9d\u636e\u3002<\/p>\n<hr \/>\n<h4>4-3 \u57fa\u672c\u4f7f\u7528<\/h4>\n<h5>\u4e00\u4e2a\u5b8c\u6574\u7684 Makefile<\/h5>\n<p>myproc:myproc.c<br \/>\ngcc -o myproc myproc.c<\/p>\n<p>.PHONY:clean<br \/>\nclean:<br \/>\nrm -f myproc<\/p>\n<p>\u8fd9\u4e2a\u6587\u4ef6\u5305\u542b\u4e24\u6761\u4e3b\u8981\u89c4\u5219&#xff1a;<\/p>\n<p>myproc  \u2190  myproc.c<br \/>\nclean   \u2190  \u65e0\u6587\u4ef6\u4f9d\u8d56<\/p>\n<p>\u7b2c\u4e00\u6761\u89c4\u5219\u8868\u793a&#xff1a;\u7a0b\u5e8f myproc \u4f9d\u8d56\u6e90\u6587\u4ef6 myproc.c&#xff0c;\u751f\u6210\u5b83\u65f6\u6267\u884c&#xff1a;<\/p>\n<p>gcc <span class=\"token parameter variable\">-o<\/span> myproc myproc.c<\/p>\n<p>\u7b2c\u4e8c\u6761\u89c4\u5219\u8868\u793a&#xff1a;\u76ee\u6807 clean \u88ab\u8c03\u7528\u65f6&#xff0c;\u6267\u884c&#xff1a;<\/p>\n<p><span class=\"token function\">rm<\/span> <span class=\"token parameter variable\">-f<\/span> myproc<\/p>\n<p>rm \u662f\u5220\u9664\u6587\u4ef6\u7684\u547d\u4ee4&#xff0c;-f \u8868\u793a\u5373\u4f7f\u6587\u4ef6\u4e0d\u5b58\u5728&#xff0c;\u4e5f\u5c3d\u91cf\u4e0d\u8981\u62a5\u9519\u3002<\/p>\n<h5>\u89c4\u5219\u7684\u4e66\u5199\u683c\u5f0f<\/h5>\n<h6>\u8bed\u6cd5<\/h6>\n<p>\u76ee\u6807:\u4f9d\u8d56<br \/>\n\u547d\u4ee4<\/p>\n<h6>\u529f\u80fd<\/h6>\n<ul>\n<li>\u76ee\u6807:\u4f9d\u8d56&#xff1a;\u58f0\u660e\u76ee\u6807\u548c\u4f9d\u8d56\u4e4b\u95f4\u7684\u5173\u7cfb&#xff1b;<\/li>\n<li>\u4e0b\u4e00\u884c\u7684\u547d\u4ee4&#xff1a;\u8bf4\u660e\u5982\u4f55\u751f\u6210\u6216\u5904\u7406\u76ee\u6807&#xff1b;<\/li>\n<li>\u76ee\u6807\u548c\u4f9d\u8d56\u5fc5\u987b\u9876\u683c\u5199&#xff1b;<\/li>\n<li>\u547d\u4ee4\u524d\u5fc5\u987b\u4f7f\u7528\u4e00\u4e2a\u771f\u6b63\u7684 Tab&#xff0c;\u4e0d\u80fd\u7528\u7a7a\u683c\u4ee3\u66ff\u3002<\/li>\n<\/ul>\n<h6>\u793a\u4f8b<\/h6>\n<p>myproc:myproc.c<br \/>\ngcc -o myproc myproc.c<\/p>\n<h6>\u6ce8\u610f\u4e8b\u9879<\/h6>\n<p>\u4e0b\u9762\u7684\u7f29\u8fdb\u5fc5\u987b\u662f Tab&#xff1a;<\/p>\n<p>myproc:myproc.c<br \/>\ngcc -o myproc myproc.c<\/p>\n<p>\u5982\u679c\u628a gcc \u524d\u9762\u7684 Tab \u6362\u6210\u7a7a\u683c&#xff0c;make \u53ef\u80fd\u62a5\u9519&#xff0c;\u56e0\u4e3a make \u7528\u7f29\u8fdb\u533a\u5206\u201c\u89c4\u5219\u58f0\u660e\u201d\u548c\u201c\u8981\u6267\u884c\u7684\u547d\u4ee4\u201d\u3002<\/p>\n<h5>\u4f7f\u7528 make<\/h5>\n<h6>\u8bed\u6cd5<\/h6>\n<p><span class=\"token function\">make<\/span> <span class=\"token punctuation\">[<\/span>\u76ee\u6807<span class=\"token punctuation\">]<\/span><\/p>\n<h6>\u529f\u80fd<\/h6>\n<ul>\n<li>\u76f4\u63a5\u6267\u884c make&#xff1a;\u6267\u884c Makefile \u4e2d\u7684\u7b2c\u4e00\u4e2a\u76ee\u6807&#xff1b;<\/li>\n<li>\u6267\u884c make clean&#xff1a;\u660e\u786e\u8981\u6c42\u6267\u884c\u540d\u4e3a clean \u7684\u76ee\u6807\u3002<\/li>\n<\/ul>\n<h6>\u793a\u4f8b<\/h6>\n<p>\u5728\u5305\u542b Makefile \u548c myproc.c \u7684\u76ee\u5f55\u4e2d\u6267\u884c&#xff1a;<\/p>\n<p><span class=\"token function\">make<\/span><\/p>\n<p>\u7b49\u4ef7\u4e8e\u8ba9 make \u6839\u636e\u7b2c\u4e00\u6761\u89c4\u5219\u51b3\u5b9a\u662f\u5426\u6267\u884c&#xff1a;<\/p>\n<p>gcc <span class=\"token parameter variable\">-o<\/span> myproc myproc.c<\/p>\n<p>\u6267\u884c\u6e05\u7406\u64cd\u4f5c&#xff1a;<\/p>\n<p><span class=\"token function\">make<\/span> clean<\/p>\n<p>\u8fd9\u4f1a\u6267\u884c&#xff1a;<\/p>\n<p><span class=\"token function\">rm<\/span> <span class=\"token parameter variable\">-f<\/span> myproc<\/p>\n<h6>\u6ce8\u610f\u4e8b\u9879<\/h6>\n<p>clean \u4e0d\u4f1a\u56e0\u4e3a\u5199\u5728 Makefile \u4e2d\u5c31\u81ea\u52a8\u6267\u884c\u3002\u76f4\u63a5\u6267\u884c make \u65f6&#xff0c;\u9ed8\u8ba4\u53ea\u5904\u7406\u7b2c\u4e00\u4e2a\u76ee\u6807&#xff0c;\u4e5f\u5c31\u662f myproc\u3002<\/p>\n<h5>.PHONY \u548c\u4f2a\u76ee\u6807<\/h5>\n<h6>\u8bed\u6cd5<\/h6>\n<p>.PHONY:\u76ee\u6807<\/p>\n<h6>\u529f\u80fd<\/h6>\n<p>.PHONY \u7528\u6765\u58f0\u660e\u4e00\u4e2a\u4f2a\u76ee\u6807\u3002\u4f2a\u76ee\u6807\u662f\u201c\u540d\u5b57\u770b\u8d77\u6765\u50cf\u76ee\u6807&#xff0c;\u4f46\u4e0d\u4e00\u5b9a\u5bf9\u5e94\u771f\u5b9e\u6587\u4ef6\u201d\u7684\u76ee\u6807\u3002<\/p>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>.PHONY:clean #\u5b8c\u6210\u6e05\u7406\u4efb\u52a1&#xff0c;\u800c\u4e0d\u662f\u751f\u6210\u4e00\u4e2aclear\u6587\u4ef6<br \/>\nclean:<br \/>\nrm -f myproc<\/p>\n<p>\u8fd9\u91cc\u7684 clean \u901a\u5e38\u4e0d\u662f\u4e00\u4e2a\u771f\u5b9e\u6587\u4ef6&#xff0c;\u800c\u662f\u4e00\u4e2a\u201c\u6267\u884c\u6e05\u7406\u547d\u4ee4\u201d\u7684\u540d\u79f0\u3002<\/p>\n<h6>\u6ce8\u610f\u4e8b\u9879<\/h6>\n<p>\u5982\u679c\u5f53\u524d\u76ee\u5f55\u4e2d\u6070\u597d\u5b58\u5728\u4e00\u4e2a\u540d\u4e3a clean \u7684\u6587\u4ef6&#xff0c;\u6ca1\u6709\u58f0\u660e .PHONY \u65f6&#xff0c;make clean \u53ef\u80fd\u8ba4\u4e3a\u76ee\u6807\u5df2\u7ecf\u5b8c\u6210&#xff0c;\u4ece\u800c\u4e0d\u6267\u884c\u547d\u4ee4\u3002<\/p>\n<p>\u58f0\u660e\u540e&#xff1a;<\/p>\n<p>.PHONY:clean<\/p>\n<p>make \u4f1a\u5ffd\u7565\u540c\u540d\u6587\u4ef6\u7684\u5f71\u54cd&#xff0c;\u6bcf\u6b21\u6267\u884c&#xff1a;<\/p>\n<p>.PHONY \u7684\u4f5c\u7528&#xff1a;\u8ba9 make \u5ffd\u7565\u6e90\u6587\u4ef6\u548c\u76ee\u6807\u6587\u4ef6\u7684\u65f6\u95f4\u5bf9\u6bd4&#xff0c;\u628a\u76ee\u6807\u5f53\u6210\u6bcf\u6b21\u90fd\u9700\u8981\u6267\u884c\u7684\u4f2a\u76ee\u6807\u3002<\/p>\n<h5>\u4e3a\u4ec0\u4e48\u4e0d\u4f1a\u91cd\u590d\u7f16\u8bd1<\/h5>\n<p>make \u4f1a\u6bd4\u8f83\u76ee\u6807\u6587\u4ef6\u548c\u4f9d\u8d56\u6587\u4ef6\u7684\u4fee\u6539\u65f6\u95f4\u3002<\/p>\n<h6>\u6587\u4ef6\u7684\u65f6\u95f4\u5c5e\u6027<\/h6>\n<p>\u6587\u4ef6\u4e0d\u4ec5\u5305\u542b\u5185\u5bb9&#xff0c;\u8fd8\u5305\u542b\u5c5e\u6027\u3002\u5e38\u89c1\u7684\u65f6\u95f4\u5c5e\u6027\u6709&#xff1a;<\/p>\n<table>\n<tr>\u5c5e\u6027\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td>Modify<\/td>\n<td>\u6587\u4ef6\u5185\u5bb9\u6700\u540e\u4e00\u6b21\u88ab\u4fee\u6539\u7684\u65f6\u95f4<\/td>\n<\/tr>\n<tr>\n<td>Change<\/td>\n<td>\u6587\u4ef6\u5c5e\u6027\u6700\u540e\u4e00\u6b21\u53d1\u751f\u53d8\u5316\u7684\u65f6\u95f4<\/td>\n<\/tr>\n<tr>\n<td>Access<\/td>\n<td>\u6587\u4ef6\u6700\u540e\u4e00\u6b21\u88ab\u8bbf\u95ee\u7684\u65f6\u95f4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5728\u5224\u65ad\u662f\u5426\u9700\u8981\u91cd\u65b0\u6784\u5efa\u65f6&#xff0c;make \u4e3b\u8981\u6bd4\u8f83\u6587\u4ef6\u7684 Modify \u65f6\u95f4\u3002<\/p>\n<h6>\u5224\u65ad\u89c4\u5219<\/h6>\n<ul>\n<li>myproc \u4e0d\u5b58\u5728&#xff1a;\u6267\u884c\u547d\u4ee4&#xff1b;<\/li>\n<li>myproc.c \u7684**\u4fee\u6539\u65f6\u95f4(Modify)**\u6bd4 myproc \u65b0&#xff1a;\u6267\u884c\u547d\u4ee4&#xff1b;<\/li>\n<li>myproc.c \u6ca1\u6709\u6bd4 myproc \u65b0&#xff1a;\u901a\u5e38\u4e0d\u6267\u884c\u547d\u4ee4\u3002<\/li>\n<\/ul>\n<p>\u56e0\u4e3a\u4f9d\u8d56\u6587\u4ef6\u66f4\u65b0\u540e&#xff0c;\u76ee\u6807\u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u8fc7\u65f6&#xff0c;\u6240\u4ee5\u9700\u8981\u91cd\u65b0\u751f\u6210\u3002<\/p>\n<p>make \u9ed8\u8ba4\u4e0d\u91cd\u590d\u7f16\u8bd1&#xff0c;\u662f\u56e0\u4e3a\u5b83\u6bd4\u8f83\u76ee\u6807\u6587\u4ef6\u548c\u4f9d\u8d56\u6587\u4ef6\u7684 Modify \u65f6\u95f4&#xff1b;\u53ea\u6709\u76ee\u6807\u4e0d\u5b58\u5728\u6216\u4f9d\u8d56\u66f4\u65b0\u5f97\u66f4\u665a\u65f6&#xff0c;\u624d\u91cd\u65b0\u6267\u884c\u547d\u4ee4\u3002<\/p>\n<hr \/>\n<h4>4-4 \u63a8\u5bfc\u8fc7\u7a0b<\/h4>\n<p>myproc  \u4f9d\u8d56 myproc.o<br \/>\nmyproc.o  \u4f9d\u8d56 myproc.s<br \/>\nmyproc.s  \u4f9d\u8d56 myproc.i<br \/>\nmyproc.i  \u4f9d\u8d56 myproc.c<\/p>\n<h5>\u50cf\u6808\u4e00\u6837\u6267\u884c<\/h5>\n<p>\u6808\u662f\u4e00\u79cd\u201c\u540e\u8fdb\u5148\u51fa\u201d\u7684\u7ed3\u6784&#xff1a;\u6700\u540e\u653e\u8fdb\u53bb\u7684\u5185\u5bb9\u6700\u5148\u53d6\u51fa\u6765\u3002<\/p>\n<p>make \u5904\u7406\u4f9d\u8d56\u94fe\u65f6&#xff0c;\u5148\u6cbf\u7740\u4f9d\u8d56\u5173\u7cfb\u5411\u4e0b\u67e5\u627e&#xff0c;\u76f4\u5230\u627e\u5230\u6700\u5e95\u5c42\u7684\u6e90\u6587\u4ef6&#xff1b;\u7136\u540e\u518d\u4ece\u5e95\u5c42\u5411\u4e0a\u9010\u5c42\u751f\u6210\u76ee\u6807&#xff1a;<\/p>\n<p>\u5411\u4e0b\u67e5\u627e&#xff1a;myproc \u2192 myproc.o \u2192 myproc.s \u2192 myproc.i \u2192 myproc.c<br \/>\n\u5411\u4e0a\u751f\u6210&#xff1a;myproc.c \u2192 myproc.i \u2192 myproc.s \u2192 myproc.o \u2192 myproc<\/p>\n<p>\u56e0\u6b64&#xff0c;\u4f9d\u8d56\u5173\u7cfb\u50cf\u5165\u6808&#xff0c;\u751f\u6210\u8fc7\u7a0b\u50cf\u51fa\u6808\u3002<\/p>\n<p>make \u5148\u6cbf\u4f9d\u8d56\u94fe\u5411\u4e0b\u5bfb\u627e\u6700\u5e95\u5c42\u6587\u4ef6&#xff0c;\u518d\u4ece\u5e95\u5c42\u5411\u4e0a\u9010\u5c42\u6267\u884c\u547d\u4ee4\u3002<\/p>\n<h5>make \u7684\u5de5\u4f5c\u65b9\u5f0f<\/h5>\n<p>\u5177\u4f53\u6765\u8bf4&#xff1a;<\/p>\n<li>make \u5148\u5bfb\u627e Makefile&#xff1b;<\/li>\n<li>\u76f4\u63a5\u6267\u884c make \u65f6&#xff0c;\u628a\u7b2c\u4e00\u4e2a\u76ee\u6807\u4f5c\u4e3a\u6700\u7ec8\u76ee\u6807&#xff1b;<\/li>\n<li>\u5982\u679c\u76ee\u6807\u4e0d\u5b58\u5728&#xff0c;\u6267\u884c\u5b83\u7684\u547d\u4ee4&#xff1b;<\/li>\n<li>\u5982\u679c\u76ee\u6807\u5b58\u5728&#xff0c;\u4f46\u4f9d\u8d56\u6587\u4ef6\u6bd4\u76ee\u6807\u66f4\u65b0&#xff0c;\u6267\u884c\u5b83\u7684\u547d\u4ee4&#xff1b;<\/li>\n<li>\u5982\u679c\u4f9d\u8d56\u6587\u4ef6\u4e0d\u5b58\u5728&#xff0c;\u7ee7\u7eed\u67e5\u627e\u201c\u5982\u4f55\u751f\u6210\u8fd9\u4e2a\u4f9d\u8d56\u201d\u7684\u89c4\u5219&#xff1b;<\/li>\n<li>\u5982\u679c\u65e2\u627e\u4e0d\u5230\u4f9d\u8d56\u6587\u4ef6&#xff0c;\u4e5f\u627e\u4e0d\u5230\u751f\u6210\u5b83\u7684\u89c4\u5219&#xff0c;\u5c31\u62a5\u9519\u9000\u51fa\u3002<\/li>\n<h5>make \u4e0d\u68c0\u67e5\u547d\u4ee4\u662f\u5426\u6b63\u786e<\/h5>\n<p>make \u53ea\u8d1f\u8d23\u6839\u636e\u6587\u4ef6\u7684\u4f9d\u8d56\u5173\u7cfb\u51b3\u5b9a\u201c\u662f\u5426\u6267\u884c\u547d\u4ee4\u201d&#xff0c;\u4e0d\u8d1f\u8d23\u5224\u65ad\u547d\u4ee4\u672c\u8eab\u662f\u5426\u6b63\u786e\u3002<\/p>\n<hr \/>\n<h4>4-5 \u9002\u5ea6\u6269\u5c55\u8bed\u6cd5<\/h4>\n<h5>\u53d8\u91cf<\/h5>\n<h6>\u8bed\u6cd5<\/h6>\n<p>\u53d8\u91cf\u540d&#061;\u503c<\/p>\n<p>\u4f7f\u7528\u53d8\u91cf\u65f6\u5199\u6210&#xff1a;<\/p>\n<p>$(\u53d8\u91cf\u540d)<\/p>\n<p>\u53d8\u91cf\u5c31\u662f\u4e00\u4e2a\u53ef\u4ee5\u53cd\u590d\u4f7f\u7528\u7684\u540d\u5b57&#xff0c;\u7528\u6765\u4fdd\u5b58\u6587\u4ef6\u540d\u3001\u547d\u4ee4\u540d\u6216\u6587\u4ef6\u5217\u8868&#xff0c;\u907f\u514d\u540c\u6837\u7684\u5185\u5bb9\u91cd\u590d\u4e66\u5199\u3002\u4f5c\u7528\u7c7b\u6bd4\u5b9a\u4e49\u5b8f<\/p>\n<h6>\u793a\u4f8b<\/h6>\n<p>BIN&#061;proc.exe<br \/>\nCC&#061;gcc<br \/>\nSRC&#061;myproc.c<br \/>\nOBJ&#061;myproc.o<br \/>\nRM&#061;rm -f<\/p>\n<p># \u4f7f\u7528\u65f6\u52a0$()<br \/>\n$(BIN):$(SRC)<br \/>\n$(CC) -o $(BIN) $(SRC)<\/p>\n<p>.PHONY:clear<br \/>\nclear:<br \/>\n$(RM) $(OBJ) $(BIN)<\/p>\n<h5>\u81ea\u52a8\u53d8\u91cf<\/h5>\n<p>\u81ea\u52a8\u53d8\u91cf\u53ea\u80fd\u5728\u89c4\u5219\u7684\u547d\u4ee4\u4e2d\u4f7f\u7528&#xff0c;make \u4f1a\u6839\u636e\u5f53\u524d\u89c4\u5219\u81ea\u52a8\u4e3a\u5b83\u4eec\u586b\u5165\u5185\u5bb9\u3002<\/p>\n<table>\n<tr>\u81ea\u52a8\u53d8\u91cf\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td>$&#064;<\/td>\n<td>\u5f53\u524d\u76ee\u6807\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>$^<\/td>\n<td>\u5f53\u524d\u89c4\u5219\u7684\u5168\u90e8\u4f9d\u8d56<\/td>\n<\/tr>\n<tr>\n<td>$&lt;<\/td>\n<td>\u5f53\u524d\u89c4\u5219\u7684\u7b2c\u4e00\u4e2a\u4f9d\u8d56<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h6>\u793a\u4f8b<\/h6>\n<p>myproc:main.o print.o<br \/>\ngcc -o $&#064; $^<\/p>\n<p># $&#064;  \u2192 myproc<br \/>\n# $^  \u2192 main.o print.o<br \/>\n# \u56e0\u6b64\u7b49\u4ef7\u4e8e&#xff1a;<br \/>\ngcc -o myproc main.o print.o<\/p>\n<h5>\u6a21\u5f0f\u5339\u914d<\/h5>\n<h6>\u8bed\u6cd5<\/h6>\n<p>%.o:%.c<br \/>\n\u547d\u4ee4<\/p>\n<h6>\u529f\u80fd<\/h6>\n<p>% \u8868\u793a\u4e00\u4e2a\u53ef\u4ee5\u53d8\u5316\u7684\u90e8\u5206\u3002%.o:%.c \u8868\u793a&#xff1a;<\/p>\n<ul>\n<li>\u4efb\u610f\u4e00\u4e2a .o \u6587\u4ef6&#xff1b;<\/li>\n<li>\u4f9d\u8d56\u540c\u540d\u7684 .c \u6587\u4ef6\u3002<\/li>\n<\/ul>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>main.o  \u2190 main.c<br \/>\nprint.o \u2190 print.c<\/p>\n<p>\u90fd\u53ef\u4ee5\u5339\u914d\u8fd9\u6761\u89c4\u5219\u3002<\/p>\n<h6>\u793a\u4f8b<\/h6>\n<p>%.o:%.c<br \/>\n$(CC) -c $&lt; -o $&#064;<\/p>\n<p>\u5f53\u5904\u7406 main.o \u65f6&#xff1a;<\/p>\n<p>$&lt;  \u2192 main.c<br \/>\n$&#064;  \u2192 main.o<\/p>\n<p>\u547d\u4ee4\u7b49\u4ef7\u4e8e&#xff1a;<\/p>\n<p>gcc <span class=\"token parameter variable\">-c<\/span> main.c <span class=\"token parameter variable\">-o<\/span> main.o<\/p>\n<h5>&#064;&#xff1a;\u4e0d\u56de\u663e\u547d\u4ee4<\/h5>\n<h6>\u8bed\u6cd5<\/h6>\n<p>\u76ee\u6807:<br \/>\n&#064;\u547d\u4ee4<\/p>\n<h6>\u529f\u80fd<\/h6>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b&#xff0c;make \u6267\u884c\u547d\u4ee4\u524d&#xff0c;\u901a\u5e38\u4f1a\u5148\u628a\u547d\u4ee4\u663e\u793a\u5728\u5c4f\u5e55\u4e0a\u3002\u5728\u547d\u4ee4\u524d\u52a0 &#064;&#xff0c;\u53ef\u4ee5\u53ea\u6267\u884c\u547d\u4ee4\u800c\u4e0d\u663e\u793a\u8fd9\u884c\u547d\u4ee4\u3002<\/p>\n<h6>\u6ce8\u610f\u4e8b\u9879<\/h6>\n<p>&#064; \u53ea\u5f71\u54cd\u547d\u4ee4\u662f\u5426\u56de\u663e&#xff0c;\u4e0d\u6539\u53d8\u547d\u4ee4\u672c\u8eab\u7684\u529f\u80fd\u3002<\/p>\n<h4>4&#xff0c;\u603b\u7ed3<\/h4>\n<h5>\u4e00\u4e2a\u5c0f\u800c\u7f8e\u7684Makefile\u6587\u4ef6\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f<\/h5>\n<p><span class=\"token assign-left variable\">BIN<\/span><span class=\"token operator\">&#061;<\/span>proc.exe<br \/>\n<span class=\"token assign-left variable\">CC<\/span><span class=\"token operator\">&#061;<\/span>gcc<br \/>\n<span class=\"token comment\">#SRC&#061;$(shell ls *.c) #\u6267\u884cshell\u547d\u4ee4&#xff0c;\u5217\u51fa\u6240\u6709.c\u6587\u4ef6<\/span><br \/>\n<span class=\"token assign-left variable\">SRC<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token variable\"><span class=\"token variable\">$(<\/span>wildcard *.c<span class=\"token variable\">)<\/span><\/span> <span class=\"token comment\"># makefile\u547d\u4ee4&#xff0c;\u5217\u51fa\u6240\u6709.c\u6587\u4ef6<\/span><br \/>\n<span class=\"token assign-left variable\">OBJ<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token variable\"><span class=\"token variable\">$(<\/span>SRC:.c<span class=\"token operator\">&#061;<\/span>.o<span class=\"token variable\">)<\/span><\/span> <span class=\"token comment\"># \u628aSRC\u91cc\u9762\u7684\u6240\u6709.c\u6587\u4ef6\u6362\u6210.o<\/span><br \/>\n<span class=\"token assign-left variable\">LFLAGS<\/span><span class=\"token operator\">&#061;<\/span>-o<br \/>\n<span class=\"token assign-left variable\">FLAGS<\/span><span class=\"token operator\">&#061;<\/span>-c<br \/>\n<span class=\"token assign-left variable\">RM<\/span><span class=\"token operator\">&#061;<\/span>rm <span class=\"token parameter variable\">-f<\/span><\/p>\n<p><span class=\"token variable\"><span class=\"token variable\">$(<\/span>BIN<span class=\"token variable\">)<\/span><\/span><span class=\"token builtin class-name\">:<\/span><span class=\"token variable\"><span class=\"token variable\">$(<\/span>OBJ<span class=\"token variable\">)<\/span><\/span><br \/>\n&#064;<span class=\"token variable\"><span class=\"token variable\">$(<\/span>CC<span class=\"token variable\">)<\/span><\/span> <span class=\"token variable\"><span class=\"token variable\">$(<\/span>LFLAGS<span class=\"token variable\">)<\/span><\/span> <span class=\"token variable\">$&#064;<\/span> $^   <span class=\"token comment\"># $^ \u5f53\u524d\u6240\u6709\u7684\u4f9d\u8d56\u6587\u4ef6&#xff0c;$&#064; \u5f53\u524d\u76ee\u6807\u6587\u4ef6&#xff0c;\u5373\u4e0a\u9762\u7684BIN<\/span><br \/>\n&#064;echo <span class=\"token string\">&#034;linking &#8230; $^ to <span class=\"token variable\">$&#064;<\/span>&#034;<\/span><\/p>\n<p>%.o:%.c<br \/>\n&#064;<span class=\"token variable\"><span class=\"token variable\">$(<\/span>CC<span class=\"token variable\">)<\/span><\/span> <span class=\"token variable\"><span class=\"token variable\">$(<\/span>FLAGS<span class=\"token variable\">)<\/span><\/span> $<span class=\"token operator\">&lt;<\/span> <span class=\"token comment\"># $&lt; \u5f53\u524d\u7684\u7b2c\u4e00\u4e2a\u4f9d\u8d56 <\/span><br \/>\n&#064;echo <span class=\"token string\">&#034;compiling &#8230; $&lt; to <span class=\"token variable\">$&#064;<\/span>&#034;<\/span><\/p>\n<p>.PHONY:clean<br \/>\nclean:<br \/>\n<span class=\"token variable\"><span class=\"token variable\">$(<\/span>RM<span class=\"token variable\">)<\/span><\/span> <span class=\"token variable\"><span class=\"token variable\">$(<\/span>OBJ<span class=\"token variable\">)<\/span><\/span> <span class=\"token variable\"><span class=\"token variable\">$(<\/span>BIN<span class=\"token variable\">)<\/span><\/span><\/p>\n<p>.PHONY:test<br \/>\ntest:<br \/>\n&#064;echo <span class=\"token variable\"><span class=\"token variable\">$(<\/span>SRC<span class=\"token variable\">)<\/span><\/span><br \/>\n&#064;echo <span class=\"token variable\"><span class=\"token variable\">$(<\/span>OBJ<span class=\"token variable\">)<\/span><\/span><\/p>\n<hr \/>\n<p>\u6548\u679c&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261011181715-6acbd2ab1767e.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>\u6838\u5fc3\u6982\u5ff5\u3010\u91cd\u70b9\u3011<\/h4>\n<ul>\n<li>make \u662f\u547d\u4ee4&#xff08;\u6267\u884c\u8005&#xff09;&#xff0c;Makefile \u662f\u6587\u4ef6&#xff08;\u89c4\u5219\u8bf4\u660e\u4e66&#xff09;\u3002<\/li>\n<li>\u89c4\u5219\u4e24\u8981\u7d20&#xff1a;\u4f9d\u8d56\u5173\u7cfb&#xff08;\u5148\u627e\u8c01&#xff09;&#043; \u4f9d\u8d56\u65b9\u6cd5&#xff08;\u627e\u5230\u540e\u505a\u4ec0\u4e48&#xff09;\u3002<\/li>\n<\/ul>\n<h4>\u89c4\u5219\u683c\u5f0f\u4e0e\u4f7f\u7528<\/h4>\n<p>myproc:myproc.c              # \u76ee\u6807:\u4f9d\u8d56&#xff08;\u9876\u683c\u5199&#xff09;<br \/>\ngcc -o myproc myproc.c   # \u547d\u4ee4\u524d\u5fc5\u987b\u662f\u4e00\u4e2a\u771f\u6b63\u7684 Tab&#xff0c;\u4e0d\u80fd\u7528\u7a7a\u683c\u3010\u6613\u9519\u3011<\/p>\n<p>.PHONY:clean                 # \u58f0\u660e\u4f2a\u76ee\u6807<br \/>\nclean:                       # \u65e0\u4f9d\u8d56<br \/>\nrm -f myproc<\/p>\n<ul>\n<li>make &#061; \u6267\u884c\u7b2c\u4e00\u4e2a\u76ee\u6807&#xff1b;make clean &#061; \u6307\u5b9a\u6267\u884c clean&#xff08;clean \u4e0d\u4f1a\u81ea\u52a8\u8dd1&#xff09;\u3002<\/li>\n<li>.PHONY \u4f5c\u7528&#xff1a;\u9632\u6b62\u76ee\u5f55\u91cc\u6070\u597d\u6709\u540c\u540d\u6587\u4ef6 clean \u5bfc\u81f4 make \u8bef\u5224&#034;\u5df2\u5b8c\u6210&#034;\u800c\u4e0d\u6267\u884c\u3002\u3010\u91cd\u70b9\u3011<\/li>\n<\/ul>\n<h4>\u4e0d\u91cd\u590d\u7f16\u8bd1\u539f\u7406\u3010\u91cd\u70b9\u3011\u3010\u6613\u5fd8\u3011<\/h4>\n<ul>\n<li>make \u6bd4\u8f83\u76ee\u6807\u4e0e\u4f9d\u8d56\u7684 Modify \u65f6\u95f4&#xff08;\u5185\u5bb9\u4fee\u6539\u65f6\u95f4&#xff09;\u3002<\/li>\n<li>\u76ee\u6807\u4e0d\u5b58\u5728 \u2192 \u6267\u884c&#xff1b;\u4f9d\u8d56\u6bd4\u76ee\u6807\u65b0 \u2192 \u6267\u884c&#xff1b;\u5426\u5219\u4e0d\u6267\u884c\u3002<\/li>\n<li>\u6587\u4ef6\u4e09\u65f6\u95f4\u3010\u6613\u6df7\u3011&#xff1a;Modify \u5185\u5bb9\u4fee\u6539 \/ Change \u5c5e\u6027\u6216\u5185\u5bb9\u53d8\u5316 \/ Access \u8bbf\u95ee\u3002<\/li>\n<li>\u63a8\u5bfc\u94fe\u50cf\u6808&#xff1a;\u5148\u6cbf\u4f9d\u8d56\u5411\u4e0b\u627e\u5230\u6700\u5e95\u5c42\u6e90\u6587\u4ef6&#xff0c;\u518d\u4ece\u5e95\u5411\u4e0a\u9010\u5c42\u751f\u6210&#xff08;\u5165\u6808\u67e5\u627e\u3001\u51fa\u6808\u751f\u6210&#xff09;\u3002<\/li>\n<li>make \u53ea\u7ba1&#034;\u662f\u5426\u6267\u884c\u547d\u4ee4&#034;&#xff0c;\u4e0d\u7ba1\u547d\u4ee4\u672c\u8eab\u5bf9\u9519&#xff08;gcc \u6ca1\u88c5\u3001\u4ee3\u7801\u6709\u9519\u5b83\u90fd\u4e0d\u7ba1&#xff09;\u3002<\/li>\n<\/ul>\n<h4>\u53d8\u91cf\u4e0e\u81ea\u52a8\u53d8\u91cf<\/h4>\n<p>BIN&#061;proc.exe                 # \u5b9a\u4e49\u53d8\u91cf&#xff0c;\u4f7f\u7528\u65f6 $(BIN)<br \/>\nSRC&#061;$(wildcard *.c)          # \u627e\u51fa\u5f53\u524d\u76ee\u5f55\u6240\u6709 .c<br \/>\nOBJ&#061;$(SRC:.c&#061;.o)             # \u540e\u7f00\u66ff\u6362&#xff1a;a.c b.c \u2192 a.o b.o<\/p>\n<p>\u3010\u6613\u6df7\u3011 \u4e09\u4e2a\u81ea\u52a8\u53d8\u91cf&#xff08;\u53ea\u80fd\u7528\u5728\u89c4\u5219\u7684\u547d\u4ee4\u91cc&#xff09;&#xff1a;<\/p>\n<table>\n<tr>\u53d8\u91cf\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td>$&#064;<\/td>\n<td>\u76ee\u6807\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>$^<\/td>\n<td>\u5168\u90e8\u4f9d\u8d56<\/td>\n<\/tr>\n<tr>\n<td>$&lt;<\/td>\n<td>\u7b2c\u4e00\u4e2a\u4f9d\u8d56<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li>\u6a21\u5f0f\u5339\u914d&#xff1a;%.o:%.c &#061; \u4efb\u610f .o \u4f9d\u8d56\u540c\u540d .c\u3002<\/li>\n<li>\u547d\u4ee4\u524d\u52a0 &#064; &#061; \u6267\u884c\u4f46\u4e0d\u56de\u663e\u8be5\u547d\u4ee4\u3002\u3010\u6613\u5fd8\u3011<\/li>\n<\/ul>\n<hr \/>\n<h3>5. Linux \u7b2c\u4e00\u4e2a\u7cfb\u7edf\u7a0b\u5e8f\u2014\u2014\u8fdb\u5ea6\u6761<\/h3>\n<p>\u8fdb\u5ea6\u6761\u770b\u8d77\u6765\u53ea\u662f\u4e0d\u65ad\u6539\u53d8\u4e00\u884c\u6587\u5b57&#xff0c;\u4f46\u5b83\u4f9d\u8d56\u4e09\u4e2a\u5173\u952e\u77e5\u8bc6&#xff1a;<\/p>\n<p>\u6253\u5370\u6587\u5b57<br \/>\n  \u2193<br \/>\n\u63a7\u5236\u5149\u6807\u56de\u5230\u884c\u9996<br \/>\n  \u2193<br \/>\n\u5237\u65b0\u8f93\u51fa\u7f13\u51b2\u533a<br \/>\n  \u2193<br \/>\n\u540c\u4e00\u884c\u88ab\u4e0d\u65ad\u8986\u76d6&#xff0c;\u5f62\u6210\u52a8\u6001\u6548\u679c<\/p>\n<hr \/>\n<h4>5-1 \u8865\u5145&#xff1a;\u56de\u8f66\u4e0e\u6362\u884c<\/h4>\n<table>\n<tr>\u5199\u6cd5\u540d\u79f0\u5b9e\u9645\u52a8\u4f5c<\/tr>\n<tbody>\n<tr>\n<td>\\\\r<\/td>\n<td>\u56de\u8f66<\/td>\n<td>\u56de\u5230\u5f53\u524d\u884c\u7684\u884c\u9996<\/td>\n<\/tr>\n<tr>\n<td>\\\\n<\/td>\n<td>\u6362\u884c<\/td>\n<td>\u79fb\u52a8\u5230\u4e0b\u4e00\u884c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\\\\r \u4e0d\u4f1a\u6362\u5230\u4e0b\u4e00\u884c&#xff0c;\u5b83\u53ea\u628a\u5149\u6807\u62c9\u56de\u5f53\u524d\u884c\u5f00\u5934&#xff1b;\\\\n \u4e5f\u4e0d\u8d1f\u8d23\u56de\u5230\u884c\u9996&#xff0c;\u5b83\u53ea\u8d1f\u8d23\u5411\u4e0b\u79fb\u52a8\u4e00\u884c\u3002<\/p>\n<p>\u5f3a\u8c03&#xff1a;\\\\r \u662f\u56de\u5230\u884c\u9996&#xff0c;\\\\n \u662f\u6362\u5230\u4e0b\u4e00\u884c&#xff0c;\u5b83\u4eec\u662f\u4e24\u4e2a\u52a8\u4f5c&#xff1b;\u952e\u76d8\u56de\u8f66\u952e\u901a\u5e38\u5bf9\u5e94 \\\\r\\\\n\u3002<\/p>\n<hr \/>\n<h4>5-2 \u884c\u7f13\u51b2\u533a<\/h4>\n<h5>5-2-1 \u4e3a\u4ec0\u4e48\u8c03\u7528 printf \u540e\u4e0d\u4e00\u5b9a\u9a6c\u4e0a\u770b\u89c1\u6587\u5b57<\/h5>\n<p>\u5047\u8bbe\u7a0b\u5e8f\u6253\u5370\u4e00\u6bb5\u6587\u5b57\u540e\u8981\u7b49\u5f85 3 \u79d2&#xff1a;<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;unistd.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;hello&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">sleep<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u6709\u65f6\u7a0b\u5e8f\u8fd0\u884c\u540e&#xff0c;\u7b49\u5f85\u671f\u95f4\u770b\u4e0d\u5230 hello&#xff0c;\u76f4\u5230\u7a0b\u5e8f\u7ed3\u675f\u624d\u663e\u793a\u3002\u8fd9\u4e0d\u662f printf \u6ca1\u6709\u6267\u884c&#xff0c;\u800c\u662f\u6587\u5b57\u6682\u65f6\u6ca1\u6709\u9001\u5230\u663e\u793a\u5668\u3002<\/p>\n<p>\u7a0b\u5e8f\u901a\u5e38\u4f1a\u5148\u628a\u8f93\u51fa\u6587\u5b57\u653e\u8fdb\u4e00\u5757\u4e34\u65f6\u5185\u5b58\u4e2d&#xff0c;\u7b49\u6761\u4ef6\u5408\u9002\u65f6\u518d\u4e00\u6b21\u6027\u9001\u51fa\u53bb\u3002\u8fd9\u5757\u4e34\u65f6\u5185\u5b58\u53eb\u7f13\u51b2\u533a&#xff1a;\u53ef\u4ee5\u628a\u5b83\u7406\u89e3\u4e3a\u201c\u5148\u6682\u5b58\u6570\u636e\u7684\u4e2d\u8f6c\u533a\u201d\u3002<\/p>\n<h5>5-2-2 \u4ec0\u4e48\u662f\u884c\u7f13\u51b2<\/h5>\n<p>\u884c\u7f13\u51b2&#xff1a;\u7a0b\u5e8f\u6682\u65f6\u4fdd\u5b58\u4e00\u884c\u8f93\u51fa&#xff0c;\u9047\u5230\u6362\u884c\u7b26 \\\\n \u65f6&#xff0c;\u901a\u5e38\u628a\u8fd9\u4e00\u884c\u9001\u5230\u663e\u793a\u8bbe\u5907\u3002\u4e0b\u9762\u6709\u4e09\u4e2a\u4f8b\u5b50<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;unistd.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u2460 printf() \u5e26 \\\\n &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<\/span><br \/>\n    <span class=\"token comment\">\/\/ \\\\n \u901a\u5e38\u4f1a\u89e6\u53d1 stdout \u5237\u65b0&#xff0c;\u56e0\u6b64 hello \u901a\u5e38\u4f1a\u7acb\u5373\u663e\u793a<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;hello\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">sleep<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u2461 printf() \u4e0d\u5e26 \\\\n &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u6ca1\u6709\u6362\u884c&#xff0c;hello \u53ef\u80fd\u6682\u65f6\u505c\u7559\u5728 stdout \u7f13\u51b2\u533a<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;hello&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">sleep<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u2462 \u4f7f\u7528 fflush(stdout) &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u624b\u52a8\u5237\u65b0 stdout&#xff0c;\u4f7f\u7f13\u51b2\u533a\u4e2d\u7684 hello \u7acb\u5373\u8f93\u51fa<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;hello&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">fflush<\/span><span class=\"token punctuation\">(<\/span><span class=\"token constant\">stdout<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">sleep<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h6>\u6ce8\u610f\u4e8b\u9879<\/h6>\n<ul>\n<li>stdout \u8868\u793a\u6807\u51c6\u8f93\u51fa&#xff0c;\u901a\u5e38\u5c31\u662f\u7ec8\u7aef\u663e\u793a\u5668\u3002<\/li>\n<li>fflush(stdout) \u53ea\u8d1f\u8d23\u201c\u628a\u5185\u5bb9\u9001\u51fa\u53bb\u201d&#xff0c;\u4e0d\u4f1a\u81ea\u52a8\u6362\u884c\u3002<\/li>\n<li>\u52a8\u6001\u8fdb\u5ea6\u6761\u901a\u5e38\u9700\u8981\u540c\u65f6\u4f7f\u7528 \\\\r \u548c fflush(stdout)\u3002<\/li>\n<\/ul>\n<h4>5-4 \u8fdb\u5ea6\u6761\u4ee3\u7801<\/h4>\n<h5>5-4-1 \u8fdb\u5ea6\u6761\u7684\u663e\u793a\u7ed3\u6784<\/h5>\n<p>\u4e00\u4e2a\u7b80\u5355\u7684\u8fdb\u5ea6\u6761\u53ef\u4ee5\u8bbe\u8ba1\u6210&#xff1a;<\/p>\n<p>[#########################                         ][53%][\/]<\/p>\n<p>\u5176\u4e2d&#xff1a;<\/p>\n<ul>\n<li>\u7b2c\u4e00\u90e8\u5206\u8868\u793a\u5df2\u7ecf\u5b8c\u6210\u7684\u8fdb\u5ea6&#xff1b;<\/li>\n<li>[53%] \u8868\u793a\u767e\u5206\u6bd4&#xff1b;<\/li>\n<li>\u6700\u540e\u7684 |\u3001\/\u3001-\u3001\\\\ \u662f\u65cb\u8f6c\u5149\u6807&#xff0c;\u7528\u6765\u8868\u793a\u7a0b\u5e8f\u4ecd\u5728\u5de5\u4f5c\u3002<\/li>\n<\/ul>\n<p>\u65cb\u8f6c\u5149\u6807\u6309\u7167\u4e0b\u9762\u7684\u987a\u5e8f\u53d8\u5316&#xff1a;<\/p>\n<p>| \u2192 \/ \u2192 &#8211; \u2192 \\\\ \u2192 |<\/p>\n<p>\u6ce8\u610f&#xff1a;\u53cd\u659c\u6760\u5728 C \u5b57\u7b26\u4e32\u4e2d\u6709\u7279\u6b8a\u542b\u4e49&#xff0c;\u56e0\u6b64\u8981\u5199\u6210 \\\\\\\\\u3002<\/p>\n<hr \/>\n<h5>5-4-2 version1&#xff1a;\u56fa\u5b9a 101 \u683c\u7684\u539f\u7406\u7248\u672c<\/h5>\n<h6>\u89e3\u51b3\u7684\u95ee\u9898<\/h6>\n<p>\u6700\u5f00\u59cb\u53ef\u4ee5\u4e0d\u8003\u8651\u771f\u5b9e\u4e0b\u8f7d\u91cf&#xff0c;\u53ea\u6a21\u62df\u4ece 0% \u589e\u957f\u5230 100%\u3002\u4e3a\u4e86\u8ba9\u8fdb\u5ea6\u6761\u9010\u683c\u589e\u52a0&#xff0c;\u51c6\u5907\u4e00\u4e2a\u56fa\u5b9a\u957f\u5ea6\u7684\u5b57\u7b26\u6570\u7ec4&#xff1a;<\/p>\n<p>[                                                  ]<\/p>\n<p>\u6bcf\u5b8c\u6210\u4e00\u70b9&#xff0c;\u5c31\u628a\u5176\u4e2d\u4e00\u4e2a\u7a7a\u683c\u6539\u6210 #&#xff0c;\u7136\u540e\u91cd\u65b0\u8f93\u51fa\u6574\u6761\u8fdb\u5ea6\u6761\u3002<\/p>\n<p>\u8fd9\u91cc\u4f7f\u7528 100 \u4e2a\u4f4d\u7f6e\u8868\u793a 0% \u5230 100%&#xff0c;\u6570\u7ec4\u8fd8\u8981\u989d\u5916\u7559\u4e00\u4e2a\u4f4d\u7f6e\u5b58\u653e\u5b57\u7b26\u4e32\u7ed3\u675f\u6807\u8bb0 \\\\0&#xff0c;\u6240\u4ee5\u6570\u7ec4\u5927\u5c0f\u662f 101\u3002<\/p>\n<h6>\u5b8c\u6574\u4ee3\u7801<\/h6>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;string.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;unistd.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ buffer \u7528\u6765\u4fdd\u5b58\u8fdb\u5ea6\u6761<\/span><br \/>\n    <span class=\"token comment\">\/\/ 100 \u4e2a\u5b57\u7b26\u7528\u4e8e\u663e\u793a\u8fdb\u5ea6&#xff0c;\u6700\u540e 1 \u4e2a\u5b57\u7b26\u7528\u4e8e\u5b58\u653e\u5b57\u7b26\u4e32\u7ed3\u675f\u7b26 &#039;\\\\0&#039;<\/span><br \/>\n    <span class=\"token keyword\">char<\/span> buffer<span class=\"token punctuation\">[<\/span><span class=\"token number\">101<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u7528\u4e8e\u8bb0\u5f55\u5f53\u524d\u65cb\u8f6c\u5149\u6807\u7684\u4f4d\u7f6e<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> spinner_index <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u65cb\u8f6c\u5149\u6807\u7684 4 \u79cd\u72b6\u6001&#xff1a;| \/ &#8211; \\\\<br \/>\n    const char spinner[] &#061; &#034;|\/-\\\\\\\\&#034;;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u5c06 buffer \u524d 100 \u4e2a\u4f4d\u7f6e\u5168\u90e8\u521d\u59cb\u5316\u4e3a\u7a7a\u683c<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u6b64\u65f6\u5f97\u5230\u7684\u662f\u4e00\u6761\u957f\u5ea6\u4e3a 100 \u7684\u7a7a\u8fdb\u5ea6\u6761<\/span><br \/>\n    <span class=\"token function\">memset<\/span><span class=\"token punctuation\">(<\/span>buffer<span class=\"token punctuation\">,<\/span> <span class=\"token char\">&#039; &#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">100<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ C \u5b57\u7b26\u4e32\u5fc5\u987b\u4ee5 &#039;\\\\0&#039; \u7ed3\u5c3e<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u56e0\u6b64 buffer[100] \u4e0d\u80fd\u7528\u4e8e\u663e\u793a\u8fdb\u5ea6&#xff0c;\u5fc5\u987b\u4fdd\u5b58 &#039;\\\\0&#039;<\/span><br \/>\n    buffer<span class=\"token punctuation\">[<\/span><span class=\"token number\">100<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token char\">&#039;\\\\0&#039;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ i \u8868\u793a\u5f53\u524d\u8fdb\u5ea6&#xff0c;\u4ece 0% \u4e00\u76f4\u5230 100%<\/span><br \/>\n    <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> i <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span> i <span class=\"token operator\">&lt;&#061;<\/span> <span class=\"token number\">100<\/span><span class=\"token punctuation\">;<\/span> i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ i &#061;&#061; 0 \u65f6\u8fd8\u6ca1\u6709\u5b8c\u6210\u4efb\u4f55\u8fdb\u5ea6&#xff0c;\u56e0\u6b64\u4e0d\u9700\u8981\u586b\u5145 &#039;#&#039;<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u4ece i &#061;&#061; 1 \u5f00\u59cb&#xff0c;\u6bcf\u5faa\u73af\u4e00\u6b21\u5c31\u5c06\u4e00\u4e2a\u7a7a\u683c\u66ff\u6362\u6210 &#039;#&#039;<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>i <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            buffer<span class=\"token punctuation\">[<\/span>i <span class=\"token operator\">&#8211;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token char\">&#039;#&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \\\\r&#xff1a;\u5c06\u5149\u6807\u79fb\u52a8\u5230\u5f53\u524d\u884c\u5f00\u5934<\/span><br \/>\n        <span class=\"token comment\">\/\/ %s&#xff1a;\u8f93\u51fa\u8fdb\u5ea6\u6761\u5b57\u7b26\u4e32<\/span><br \/>\n        <span class=\"token comment\">\/\/ %3d&#xff1a;\u767e\u5206\u6bd4\u81f3\u5c11\u5360 3 \u4e2a\u5b57\u7b26&#xff0c;\u4fdd\u8bc1 0~100 \u7684\u663e\u793a\u5bbd\u5ea6\u4e00\u81f4<\/span><br \/>\n        <span class=\"token comment\">\/\/ %%&#xff1a;printf \u4e2d\u8f93\u51fa\u5b57\u9762\u91cf &#039;%&#039;<\/span><br \/>\n        <span class=\"token comment\">\/\/ %c&#xff1a;\u8f93\u51fa\u5f53\u524d\u65cb\u8f6c\u5149\u6807\u5b57\u7b26<\/span><br \/>\n        <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\\\\r[%s][%3d%%][%c]&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n               buffer<span class=\"token punctuation\">,<\/span><br \/>\n               i<span class=\"token punctuation\">,<\/span><br \/>\n               spinner<span class=\"token punctuation\">[<\/span>spinner_index<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ stdout \u9ed8\u8ba4\u53ef\u80fd\u5b58\u5728\u7f13\u51b2<\/span><br \/>\n        <span class=\"token comment\">\/\/ fflush(stdout) \u5f3a\u5236\u7acb\u5373\u5237\u65b0\u8f93\u51fa&#xff0c;\u8ba9\u8fdb\u5ea6\u6761\u5b9e\u65f6\u663e\u793a<\/span><br \/>\n        <span class=\"token function\">fflush<\/span><span class=\"token punctuation\">(<\/span><span class=\"token constant\">stdout<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u65cb\u8f6c\u5149\u6807\u4e0b\u6807\u5faa\u73af&#xff1a;<\/span><br \/>\n        <span class=\"token comment\">\/\/ 0 -&gt; 1 -&gt; 2 -&gt; 3 -&gt; 0 -&gt; &#8230;<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u5bf9\u5e94&#xff1a;<\/span><br \/>\n        <span class=\"token comment\">\/\/ | -&gt; \/ -&gt; &#8211; -&gt; \\\\ -&gt; | -&gt; &#8230;<\/span><br \/>\n        spinner_index <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span>spinner_index <span class=\"token operator\">&#043;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">%<\/span> <span class=\"token number\">4<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u6682\u505c 50000 \u5fae\u79d2&#xff0c;\u5373 50 \u6beb\u79d2<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u63a7\u5236\u8fdb\u5ea6\u6761\u66f4\u65b0\u901f\u5ea6<\/span><br \/>\n        <span class=\"token function\">usleep<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">50000<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u8fdb\u5ea6\u5b8c\u6210\u540e\u6362\u884c<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h5>5-4-3 version2&#xff1a;\u6839\u636e\u771f\u5b9e\u8fdb\u5ea6\u66f4\u65b0<\/h5>\n<h6>\u4e3a\u4ec0\u4e48\u9700\u8981\u771f\u5b9e\u8fdb\u5ea6<\/h6>\n<p>\u6a21\u62df\u7a0b\u5e8f\u53ef\u4ee5\u76f4\u63a5\u7528 i \u8868\u793a\u767e\u5206\u6bd4&#xff0c;\u4f46\u771f\u5b9e\u4e0b\u8f7d\u65f6\u901a\u5e38\u77e5\u9053\u7684\u662f&#xff1a;<\/p>\n<ul>\n<li>\u603b\u5927\u5c0f total&#xff1b;<\/li>\n<li>\u5f53\u524d\u5df2\u7ecf\u4e0b\u8f7d\u7684\u5927\u5c0f current\u3002<\/li>\n<\/ul>\n<p>\u4f8b\u5982&#xff0c;\u603b\u6587\u4ef6\u5927\u5c0f\u662f 200 MB&#xff0c;\u5df2\u7ecf\u4e0b\u8f7d 100 MB&#xff1a;<\/p>\n<p>\u767e\u5206\u6bd4 &#061; current \/ total \u00d7 100<br \/>\n       &#061; 100 \/ 200 \u00d7 100<br \/>\n       &#061; 50%<\/p>\n<h6>\u5b8c\u6574\u4ee3\u7801<\/h6>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;unistd.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u5237\u65b0\u5e76\u663e\u793a\u8fdb\u5ea6\u6761<\/span><br \/>\n<span class=\"token comment\">\/\/ total&#xff1a;\u4efb\u52a1\u603b\u91cf<\/span><br \/>\n<span class=\"token comment\">\/\/ current&#xff1a;\u5f53\u524d\u5df2\u7ecf\u5b8c\u6210\u7684\u4efb\u52a1\u91cf<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">FlushProcess<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> total<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> current<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u8fdb\u5ea6\u6761\u7684\u603b\u5bbd\u5ea6\u4e3a 50 \u4e2a\u5b57\u7b26<\/span><br \/>\n    <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">int<\/span> bar_width <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">50<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u65cb\u8f6c\u5149\u6807\u7684 4 \u79cd\u72b6\u6001<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u6ce8\u610f&#xff1a;\\\\ \u662f\u8f6c\u4e49\u5b57\u7b26&#xff0c;\u56e0\u6b64\u9700\u8981\u5199\u6210 &#034;\\\\\\\\&#034;<\/span><br \/>\n    <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">char<\/span> spinner<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;|\/-\\\\\\\\&#034;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ static \u53d8\u91cf\u53ea\u521d\u59cb\u5316\u4e00\u6b21<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u51fd\u6570\u6bcf\u6b21\u8c03\u7528\u7ed3\u675f\u540e&#xff0c;spinner_index \u7684\u503c\u4e0d\u4f1a\u4e22\u5931<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u56e0\u6b64\u53ef\u4ee5\u5728\u591a\u6b21\u8c03\u7528 FlushProcess() \u65f6\u4e0d\u65ad\u5207\u6362\u65cb\u8f6c\u5149\u6807<\/span><br \/>\n    <span class=\"token keyword\">static<\/span> <span class=\"token keyword\">int<\/span> spinner_index <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u5982\u679c\u603b\u4efb\u52a1\u91cf &lt;&#061; 0&#xff0c;\u6ca1\u6709\u610f\u4e49&#xff0c;\u76f4\u63a5\u8fd4\u56de<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>total <span class=\"token operator\">&lt;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">return<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u9632\u6b62 current \u8d85\u8fc7 total<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u4f8b\u5982 total &#061; 100&#xff0c;current &#061; 120 \u65f6&#xff0c;\u6309\u7167 100% \u5904\u7406<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>current <span class=\"token operator\">&gt;<\/span> total<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        current <span class=\"token operator\">&#061;<\/span> total<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u6839\u636e\u5f53\u524d\u5b8c\u6210\u91cf\u8ba1\u7b97\u767e\u5206\u6bd4<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u4f8b\u5982&#xff1a;current &#061; 25&#xff0c;total &#061; 100<\/span><br \/>\n    <span class=\"token comment\">\/\/ percent &#061; 25 * 100 \/ 100 &#061; 25<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> percent <span class=\"token operator\">&#061;<\/span> current <span class=\"token operator\">*<\/span> <span class=\"token number\">100<\/span> <span class=\"token operator\">\/<\/span> total<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u6839\u636e\u5f53\u524d\u5b8c\u6210\u91cf\u8ba1\u7b97\u8fdb\u5ea6\u6761\u4e2d\u9700\u8981\u586b\u5145\u591a\u5c11\u4e2a &#039;#&#039;<\/span><br \/>\n    <span class=\"token comment\">\/\/ bar_width &#061; 50<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u4f8b\u5982\u5b8c\u6210 50%&#xff0c;filled &#061; 25<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> filled <span class=\"token operator\">&#061;<\/span> current <span class=\"token operator\">*<\/span> bar_width <span class=\"token operator\">\/<\/span> total<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \\\\r&#xff1a;\u5c06\u5149\u6807\u79fb\u52a8\u5230\u5f53\u524d\u884c\u5f00\u5934<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u8fd9\u6837\u53ef\u4ee5\u8986\u76d6\u4e4b\u524d\u663e\u793a\u7684\u8fdb\u5ea6\u6761&#xff0c;\u5b9e\u73b0\u52a8\u6001\u5237\u65b0<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\\\\r[&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u7ed8\u5236 50 \u4e2a\u5b57\u7b26\u7684\u8fdb\u5ea6\u6761<\/span><br \/>\n    <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> i <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span> i <span class=\"token operator\">&lt;<\/span> bar_width<span class=\"token punctuation\">;<\/span> i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u5982\u679c\u5f53\u524d\u4f4d\u7f6e\u5c0f\u4e8e filled<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u8bf4\u660e\u8fd9\u4e2a\u4f4d\u7f6e\u5df2\u7ecf\u5b8c\u6210&#xff0c;\u7528 &#039;#&#039; \u8868\u793a<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>i <span class=\"token operator\">&lt;<\/span> filled<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;#&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token comment\">\/\/ \u5426\u5219\u7528\u7a7a\u683c\u8868\u793a\u8fd8\u6ca1\u6709\u5b8c\u6210<\/span><br \/>\n            <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034; &#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u8f93\u51fa\u8fdb\u5ea6\u6761\u53f3\u8fb9\u7684\u767e\u5206\u6bd4\u548c\u65cb\u8f6c\u5149\u6807<\/span><br \/>\n    <span class=\"token comment\">\/\/ %3d&#xff1a;\u767e\u5206\u6bd4\u81f3\u5c11\u5360 3 \u4e2a\u5b57\u7b26&#xff0c;\u4fdd\u8bc1 0~100 \u663e\u793a\u5bbd\u5ea6\u4e00\u81f4<\/span><br \/>\n    <span class=\"token comment\">\/\/ %%&#xff1a;printf \u4e2d\u8f93\u51fa\u5b57\u9762\u91cf &#039;%&#039;<\/span><br \/>\n    <span class=\"token comment\">\/\/ %c&#xff1a;\u8f93\u51fa\u4e00\u4e2a\u65cb\u8f6c\u5149\u6807\u5b57\u7b26<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;][%3d%%][%c]&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n           percent<span class=\"token punctuation\">,<\/span><br \/>\n           spinner<span class=\"token punctuation\">[<\/span>spinner_index<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ stdout \u9ed8\u8ba4\u53ef\u80fd\u5b58\u5728\u7f13\u51b2<\/span><br \/>\n    <span class=\"token comment\">\/\/ fflush() \u5f3a\u5236\u7acb\u5373\u5237\u65b0\u8f93\u51fa&#xff0c;\u4f7f\u8fdb\u5ea6\u6761\u80fd\u591f\u5b9e\u65f6\u663e\u793a<\/span><br \/>\n    <span class=\"token function\">fflush<\/span><span class=\"token punctuation\">(<\/span><span class=\"token constant\">stdout<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u66f4\u65b0\u65cb\u8f6c\u5149\u6807\u4e0b\u6807<\/span><br \/>\n    <span class=\"token comment\">\/\/ 0 -&gt; 1 -&gt; 2 -&gt; 3 -&gt; 0 -&gt; &#8230;<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u5bf9\u5e94&#xff1a;<\/span><br \/>\n    <span class=\"token comment\">\/\/ | -&gt; \/ -&gt; &#8211; -&gt; \\\\ -&gt; | -&gt; &#8230;<\/span><br \/>\n    spinner_index <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span>spinner_index <span class=\"token operator\">&#043;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">%<\/span> <span class=\"token number\">4<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u8bbe\u7f6e\u4efb\u52a1\u603b\u91cf\u4e3a 100<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> total <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">100<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ current \u8868\u793a\u5f53\u524d\u5df2\u7ecf\u5b8c\u6210\u7684\u4efb\u52a1\u91cf<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u4ece 0 \u5f00\u59cb&#xff0c;\u4e00\u76f4\u589e\u52a0\u5230 total<\/span><br \/>\n    <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> current <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span> current <span class=\"token operator\">&lt;&#061;<\/span> total<span class=\"token punctuation\">;<\/span> current<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u6839\u636e\u5f53\u524d\u8fdb\u5ea6\u5237\u65b0\u8fdb\u5ea6\u6761<\/span><br \/>\n        <span class=\"token function\">FlushProcess<\/span><span class=\"token punctuation\">(<\/span>total<span class=\"token punctuation\">,<\/span> current<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u6682\u505c 50000 \u5fae\u79d2&#xff0c;\u5373 50 \u6beb\u79d2<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u63a7\u5236\u8fdb\u5ea6\u6761\u7684\u5237\u65b0\u901f\u5ea6<\/span><br \/>\n        <span class=\"token function\">usleep<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">50000<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u8fdb\u5ea6\u5b8c\u6210\u540e\u6362\u884c<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h5>5-4-4 \u914d\u5957 Makefile&#xff1a;\u81ea\u52a8\u5316\u6784\u5efa\u591a\u4e2a\u6e90\u6587\u4ef6<\/h5>\n<h6>\u5b8c\u6574 Makefile<\/h6>\n<p>BIN&#061;processbar.exe<br \/>\nSRC&#061;$(wildcard *.c)<br \/>\nOBJ&#061;$(SRC:.c&#061;.o)<br \/>\n$(BIN):$(OBJ)<br \/>\ngcc -o $&#064; $^<br \/>\n%.o:%.c<br \/>\ngcc -c $&lt; -o $&#064;<br \/>\n.PHONY:clean<br \/>\nclean:<br \/>\nrm -f $(OBJ) $(BIN)<\/p>\n<h4>\u603b\u7ed3&#xff1a;5. \u7b2c\u4e00\u4e2a\u7cfb\u7edf\u7a0b\u5e8f&#xff1a;\u8fdb\u5ea6\u6761<\/h4>\n<h5>\u56de\u8f66 vs \u6362\u884c\u3010\u6613\u6df7\u3011\u3010\u91cd\u70b9\u3011<\/h5>\n<table>\n<tr>\u5199\u6cd5\u540d\u79f0\u52a8\u4f5c<\/tr>\n<tbody>\n<tr>\n<td>\\\\r<\/td>\n<td>\u56de\u8f66<\/td>\n<td>\u56de\u5230\u5f53\u524d\u884c\u884c\u9996&#xff08;\u4e0d\u6362\u884c&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\\\\n<\/td>\n<td>\u6362\u884c<\/td>\n<td>\u79fb\u5230\u4e0b\u4e00\u884c&#xff08;\u4e0d\u56de\u884c\u9996&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u952e\u76d8\u56de\u8f66\u952e \u2248 \\\\r\\\\n \u4e24\u4e2a\u52a8\u4f5c\u5408\u4e00&#xff08;\u8001\u5f0f\u6253\u5b57\u673a&#xff1a;\u6253\u5b57\u5934\u79fb\u52a8 &#043; \u7eb8\u5f20\u79fb\u52a8&#xff09;\u3002<\/p>\n<h5>\u884c\u7f13\u51b2\u533a\u3010\u91cd\u70b9\u3011<\/h5>\n<ul>\n<li>printf \u7684\u6587\u5b57\u5148\u8fdb\u7f13\u51b2\u533a&#xff08;\u4e2d\u8f6c\u6682\u5b58\u533a&#xff09;&#xff0c;\u4e0d\u4e00\u5b9a\u7acb\u523b\u663e\u793a\u3002<\/li>\n<li>\u884c\u7f13\u51b2&#xff1a;\u9047\u5230 \\\\n \u624d\u9001\u51fa&#xff1b;\u7f13\u51b2\u533a\u6ee1\u3001\u7a0b\u5e8f\u7ed3\u675f\u4e5f\u4f1a\u89e6\u53d1\u5237\u65b0\u3002<\/li>\n<li>\u624b\u52a8\u5237\u65b0&#xff1a;fflush(stdout); \u2014\u2014 \u53ea\u8d1f\u8d23\u9001\u51fa&#xff0c;\u4e0d\u6362\u884c\u3002<\/li>\n<li>\u4e09\u4e2a\u6807\u51c6\u6d41\u3010\u6613\u5fd8\u3011&#xff1a;stdin \u952e\u76d8\u8f93\u5165 \/ stdout \u5c4f\u5e55\u8f93\u51fa \/ stderr \u9519\u8bef\u8f93\u51fa&#xff1b;\u7ec8\u7aef\u662f\u5b57\u7b26\u8bbe\u5907\u3002<\/li>\n<\/ul>\n<h5>\u52a8\u6001\u663e\u793a\u6838\u5fc3\u7ec4\u5408\u3010\u91cd\u70b9\u3011<\/h5>\n<p><span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;%-2d\\\\r&#034;<\/span><span class=\"token punctuation\">,<\/span> i<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>   # <span class=\"token operator\">%<\/span><span class=\"token operator\">&#8211;<\/span><span class=\"token number\">2<\/span>d&#xff1a;\u5bbd\u5ea6<span class=\"token number\">2<\/span>\u5de6\u5bf9\u9f50&#xff08;\u9632\u6b62 <span class=\"token number\">10<\/span>\u2192<span class=\"token number\">9<\/span> \u6b8b\u7559\u5b57\u7b26&#xff09;&#xff1b;\\\\r&#xff1a;\u56de\u884c\u9996\u8986\u76d6<br \/>\n<span class=\"token function\">fflush<\/span><span class=\"token punctuation\">(<\/span><span class=\"token constant\">stdout<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>        # \u7acb\u5373\u5237\u65b0&#xff0c;\u5426\u5219\u7559\u5728\u7f13\u51b2\u533a\u770b\u4e0d\u5230\u53d8\u5316<\/p>\n<h5>\u8fdb\u5ea6\u6761\u5b9e\u73b0\u8981\u70b9<\/h5>\n<ul>\n<li>\u7ed3\u6784&#xff1a;[#### ][53%][\/] &#061; \u5df2\u5b8c\u6210 &#043; \u767e\u5206\u6bd4 &#043; \u65cb\u8f6c\u5149\u6807 |\/-\\\\&#xff08;C \u5b57\u7b26\u4e32\u91cc\u53cd\u659c\u6760\u5199 \\\\\\\\&#xff09;\u3002<\/li>\n<li>v1&#xff1a;\u56fa\u5b9a 101 \u683c\u6570\u7ec4&#xff08;100 \u683c &#043; \\\\0&#xff09;&#xff0c;\u6bcf\u8f6e\u586b\u4e00\u4e2a #&#xff0c;\\\\r \u91cd\u7ed8\u3002<\/li>\n<li>v2&#xff1a;percent &#061; current * 100 \/ total&#xff0c;filled &#061; current * bar_width \/ total&#xff0c;\u771f\u5b9e\u4e0b\u8f7d\u6bcf\u5b8c\u6210\u4e00\u5757\u8c03\u4e00\u6b21\u5237\u65b0\u3002<\/li>\n<li>%3d \u56fa\u5b9a\u767e\u5206\u6bd4\u5bbd\u5ea6&#xff0c;\u9632\u6296\u52a8&#xff1b;%% \u8f93\u51fa\u5b57\u9762\u91cf %\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3>6. \u7248\u672c\u63a7\u5236\u5668 Git<\/h3>\n<p>\u7248\u672c\u63a7\u5236\u5668&#xff1a;\u81ea\u52a8\u8bb0\u5f55\u6587\u4ef6\u6bcf\u6b21\u6539\u52a8\u548c\u7248\u672c\u53d8\u5316\u7684\u8f6f\u4ef6\u3002\u5b83\u4e0d\u4ec5\u80fd\u4fdd\u5b58\u5386\u53f2\u7248\u672c&#xff0c;\u8fd8\u80fd\u5e2e\u52a9\u591a\u4eba\u540c\u65f6\u5f00\u53d1\u540c\u4e00\u4e2a\u9879\u76ee\u3002<\/p>\n<p>\u7248\u672c\u63a7\u5236\u5668\u4e3b\u8981\u89e3\u51b3\u4e24\u4e2a\u95ee\u9898&#xff1a;<\/p>\n<li>\u6570\u636e\u5b89\u5168&#xff1a;\u6587\u4ef6\u6539\u9519\u6216\u8bef\u5220\u540e&#xff0c;\u53ef\u4ee5\u627e\u56de\u4ee5\u524d\u7684\u7248\u672c\u3002<\/li>\n<li>\u534f\u4f5c\u5f00\u53d1&#xff1a;\u591a\u4eba\u4fee\u6539\u540c\u4e00\u4e2a\u9879\u76ee\u65f6&#xff0c;\u53ef\u4ee5\u4ea4\u6362\u5404\u81ea\u7684\u4fee\u6539&#xff0c;\u5e76\u8bb0\u5f55\u662f\u8c01\u3001\u4ec0\u4e48\u65f6\u5019\u6539\u4e86\u4ec0\u4e48\u3002<\/li>\n<h5>Git\u3001\u672c\u5730\u4ed3\u5e93\u548c\u8fdc\u7aef\u4ed3\u5e93<\/h5>\n<p>\u5982\u679c\u6bcf\u4e2a\u4eba\u90fd\u628a\u9879\u76ee\u6587\u4ef6\u653e\u5728\u81ea\u5df1\u7535\u8111\u4e0a&#xff0c;\u5176\u4ed6\u4eba\u65e0\u6cd5\u65b9\u4fbf\u5730\u83b7\u53d6\u6700\u65b0\u4fee\u6539\u3002\u56e0\u6b64&#xff0c;\u9700\u8981\u4e00\u4e2a\u4e13\u95e8\u4fdd\u5b58\u9879\u76ee\u5386\u53f2\u8bb0\u5f55\u7684\u5730\u65b9\u3002<\/p>\n<p>Git&#xff1a;\u4e00\u79cd\u7248\u672c\u63a7\u5236\u5668\u8f6f\u4ef6&#xff0c;\u8d1f\u8d23\u8bb0\u5f55\u6587\u4ef6\u53d8\u5316\u3001\u4fdd\u5b58\u7248\u672c\u5e76\u540c\u6b65\u4fee\u6539\u3002<\/p>\n<p>\u4ed3\u5e93&#xff1a;\u4fdd\u5b58\u9879\u76ee\u6587\u4ef6\u548c\u7248\u672c\u5386\u53f2\u8bb0\u5f55\u7684\u5730\u65b9\u3002\u53ef\u4ee5\u628a\u5b83\u7406\u89e3\u6210\u201c\u9879\u76ee\u6587\u4ef6\u5939\u52a0\u4e0a\u5b8c\u6574\u7684\u4fee\u6539\u8bb0\u5f55\u201d\u3002<\/p>\n<p>Git \u901a\u5e38\u6d89\u53ca\u4e24\u4e2a\u4ed3\u5e93&#xff1a;<\/p>\n<table>\n<tr>\u540d\u79f0\u4fdd\u5b58\u4f4d\u7f6e\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>\u672c\u5730\u4ed3\u5e93<\/td>\n<td>\u81ea\u5df1\u7684\u7535\u8111<\/td>\n<td>\u4fdd\u5b58\u81ea\u5df1\u63d0\u4ea4\u7684\u7248\u672c<\/td>\n<\/tr>\n<tr>\n<td>\u8fdc\u7aef\u4ed3\u5e93<\/td>\n<td>\u4e91\u670d\u52a1\u5668\u6216\u5176\u4ed6\u670d\u52a1\u5668<\/td>\n<td>\u8ba9\u591a\u4eba\u5171\u4eab\u548c\u5907\u4efd\u9879\u76ee<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Git \u65e2\u53ef\u4ee5\u4f5c\u4e3a\u64cd\u4f5c\u672c\u5730\u4ed3\u5e93\u7684\u5de5\u5177&#xff0c;\u4e5f\u53ef\u4ee5\u901a\u8fc7\u7f51\u7edc\u548c\u5176\u4ed6\u4ed3\u5e93\u4ea4\u6362\u6570\u636e&#xff0c;\u6240\u4ee5\u5b83\u65e2\u662f client&#xff08;\u5ba2\u6237\u7aef&#xff1a;\u4e3b\u52a8\u8fde\u63a5\u5e76\u64cd\u4f5c\u5176\u4ed6\u4ed3\u5e93\u7684\u4e00\u65b9&#xff09;&#xff0c;\u4e5f\u80fd\u4f5c\u4e3a server&#xff08;\u670d\u52a1\u5668\u7aef&#xff1a;\u5411\u5176\u4ed6\u7535\u8111\u63d0\u4f9b\u4ed3\u5e93\u6570\u636e\u7684\u4e00\u65b9&#xff09;\u3002<\/p>\n<p>GitHub \u548c Gitee \u662f\u57fa\u4e8e Git \u5efa\u7acb\u7684\u7f51\u7ad9\u5e73\u53f0\u3002\u5b83\u4eec\u63d0\u4f9b\u4e91\u7aef\u4ed3\u5e93\u3001\u7f51\u9875\u7ba1\u7406\u548c\u591a\u4eba\u534f\u4f5c\u529f\u80fd&#xff0c;\u4f46\u5b83\u4eec\u672c\u8eab\u4e0d\u662f Git \u8f6f\u4ef6\u3002<\/p>\n<p>Git \u662f\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf&#xff1a;\u6bcf\u4e2a\u5f00\u53d1\u8005\u7684\u672c\u5730\u4ed3\u5e93\u90fd\u4fdd\u5b58\u5b8c\u6574\u7684\u7248\u672c\u5386\u53f2&#xff0c;\u4e0d\u662f\u53ea\u80fd\u4f9d\u8d56\u4e00\u4e2a\u4e2d\u592e\u670d\u52a1\u5668\u3002\u5373\u4f7f\u6682\u65f6\u6ca1\u6709\u7f51\u7edc&#xff0c;\u4e5f\u53ef\u4ee5\u5728\u672c\u5730\u67e5\u770b\u5386\u53f2\u3001\u521b\u5efa\u7248\u672c&#xff1b;\u8054\u7f51\u540e\u518d\u4e0e\u8fdc\u7aef\u4ed3\u5e93\u540c\u6b65\u3002<\/p>\n<p>\u672c\u5730\u4ed3\u5e93\u4fdd\u8bc1\u672c\u5730\u5f00\u53d1\u548c\u5386\u53f2\u8bb0\u5f55&#xff0c;\u8fdc\u7aef\u4ed3\u5e93\u7528\u4e8e\u5907\u4efd\u548c\u591a\u4eba\u5171\u4eab\u3002<\/p>\n<hr \/>\n<h4>6-2 Git \u7b80\u53f2<\/h4>\n<p>Linux \u5185\u6838\u662f\u4e00\u4e2a\u975e\u5e38\u5927\u7684\u5f00\u6e90\u9879\u76ee&#xff0c;\u9700\u8981\u5f88\u591a\u4eba\u957f\u671f\u5171\u540c\u7ef4\u62a4\u3002\u65e9\u671f\u6ca1\u6709 Git&#xff0c;\u5f00\u53d1\u8005\u4e3b\u8981\u4f9d\u9760\u624b\u5de5\u53d1\u9001\u548c\u5408\u5e76\u8865\u4e01\u3002<\/p>\n<p>\u8865\u4e01&#xff1a;\u63cf\u8ff0\u201c\u5e94\u8be5\u5bf9\u539f\u6587\u4ef6\u505a\u54ea\u4e9b\u4fee\u6539\u201d\u7684\u6587\u4ef6\u3002<\/p>\n<p>\u53d1\u5c55\u8fc7\u7a0b\u5982\u4e0b&#xff1a;<\/p>\n<p>1991\u20142002&#xff1a;\u4e3b\u8981\u4f9d\u9760\u624b\u5de5\u8865\u4e01\u7ef4\u62a4 Linux \u5185\u6838<br \/>\n       \u2193<br \/>\n2002&#xff1a;\u4f7f\u7528\u5546\u4e1a\u7248\u672c\u63a7\u5236\u8f6f\u4ef6 BitKeeper<br \/>\n       \u2193<br \/>\n2005&#xff1a;BitKeeper \u4e0d\u518d\u514d\u8d39\u63d0\u4f9b<br \/>\n       \u2193<br \/>\nLinus Torvalds \u81ea\u5df1\u5f00\u53d1 Git<\/p>\n<p>Git \u7684\u8bbe\u8ba1\u76ee\u6807\u662f&#xff1a;<\/p>\n<ul>\n<li>\u901f\u5ea6\u5feb&#xff1a;\u5feb\u901f\u5904\u7406\u5927\u91cf\u6587\u4ef6\u548c\u4fee\u6539\u8bb0\u5f55\u3002<\/li>\n<li>\u8bbe\u8ba1\u7b80\u5355&#xff1a;\u6838\u5fc3\u64cd\u4f5c\u5c3d\u91cf\u6e05\u6670\u76f4\u63a5\u3002<\/li>\n<li>\u652f\u6301\u975e\u7ebf\u6027\u5f00\u53d1&#xff1a;\u53ef\u4ee5\u8ba9\u5f88\u591a\u5f00\u53d1\u5206\u652f\u540c\u65f6\u8fdb\u884c&#xff0c;\u518d\u5408\u5e76\u7ed3\u679c\u3002<\/li>\n<li>\u5b8c\u5168\u5206\u5e03\u5f0f&#xff1a;\u6bcf\u4e2a\u672c\u5730\u4ed3\u5e93\u90fd\u62e5\u6709\u5b8c\u6574\u5386\u53f2&#xff0c;\u4e0d\u5b8c\u5168\u4f9d\u8d56\u4e2d\u592e\u670d\u52a1\u5668\u3002<\/li>\n<li>\u9002\u5408\u8d85\u5927\u9879\u76ee&#xff1a;\u80fd\u591f\u9ad8\u6548\u7ba1\u7406\u50cf Linux \u5185\u6838\u8fd9\u6837\u7684\u5de8\u5927\u5de5\u7a0b\u3002<\/li>\n<\/ul>\n<p>\u5206\u652f&#xff1a;\u4ece\u9879\u76ee\u5f53\u524d\u7248\u672c\u5206\u51fa\u7684\u4e00\u6761\u72ec\u7acb\u5f00\u53d1\u7ebf\u8def\u3002\u4f8b\u5982&#xff0c;\u4e00\u7ec4\u4eba\u5f00\u53d1\u767b\u5f55\u529f\u80fd&#xff0c;\u53e6\u4e00\u7ec4\u4eba\u5f00\u53d1\u652f\u4ed8\u529f\u80fd&#xff0c;\u53ef\u4ee5\u5206\u522b\u5728\u4e0d\u540c\u5206\u652f\u4e2d\u5de5\u4f5c\u3002<\/p>\n<hr \/>\n<h4>6-3 \u5b89\u88c5 Git<\/h4>\n<p>\u4e0d\u540c Linux \u7cfb\u7edf\u4f7f\u7528\u7684\u5b89\u88c5\u5de5\u5177\u4e0d\u540c\u3002<\/p>\n<p><span class=\"token function\">sudo<\/span> yum <span class=\"token function\">install<\/span> <span class=\"token function\">git<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> <span class=\"token parameter variable\">-y<\/span> <span class=\"token function\">git<\/span><\/p>\n<p><span class=\"token function\">git<\/span> <span class=\"token parameter variable\">&#8211;version<\/span> <span class=\"token comment\"># \u9a8c\u8bc1\u5b89\u88c5\u7ed3\u679c<\/span><\/p>\n<h4>6-4 \u5728 GitHub \u521b\u5efa\u9879\u76ee<\/h4>\n<p>\u5982\u679c\u60f3\u628a\u672c\u5730\u9879\u76ee\u4fdd\u5b58\u5230\u4e91\u7aef\u5e76\u4e0e\u4ed6\u4eba\u534f\u4f5c&#xff0c;\u9700\u8981\u5148\u5728 GitHub \u4e0a\u521b\u5efa\u4e00\u4e2a\u8fdc\u7aef\u4ed3\u5e93\u3002<\/p>\n<h5>\u521b\u5efa\u8fdc\u7aef\u4ed3\u5e93<\/h5>\n<p>\u64cd\u4f5c\u6d41\u7a0b&#xff1a;<\/p>\n<li>\u6ce8\u518c GitHub \u8d26\u53f7\u3002<\/li>\n<li>\u6309\u8981\u6c42\u9a8c\u8bc1\u90ae\u7bb1\u3002<\/li>\n<li>\u767b\u5f55\u540e\u70b9\u51fb New repository\u3002<\/li>\n<li>\u8f93\u5165\u9879\u76ee\u540d\u79f0\u5e76\u521b\u5efa\u9879\u76ee\u3002<\/li>\n<li>\u590d\u5236\u9879\u76ee\u94fe\u63a5\u3002<\/li>\n<p>\u9879\u76ee\u94fe\u63a5\u901a\u5e38\u7c7b\u4f3c&#xff1a;<\/p>\n<p>https:\/\/github.com\/\u7528\u6237\u540d\/\u9879\u76ee\u540d.git<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261011181715-6acbd2ab58265.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u4ed3\u5e93\u94fe\u63a5&#xff1a;\u8fdc\u7aef\u4ed3\u5e93\u5728\u7f51\u7edc\u4e0a\u7684\u5730\u5740&#xff0c;Git \u6839\u636e\u8fd9\u4e2a\u5730\u5740\u8fde\u63a5\u4ed3\u5e93\u3002<\/p>\n<h5>\u4f7f\u7528 git clone \u4e0b\u8f7d\u9879\u76ee<\/h5>\n<p>\u5982\u679c\u8fdc\u7aef\u5df2\u7ecf\u6709\u4e00\u4e2a\u9879\u76ee&#xff0c;\u9700\u8981\u5148\u628a\u5b83\u590d\u5236\u5230\u672c\u5730\u3002<\/p>\n<p>\u8bed\u6cd5&#xff1a;<\/p>\n<p><span class=\"token function\">git<\/span> clone <span class=\"token punctuation\">[<\/span>url<span class=\"token punctuation\">]<\/span> <span class=\"token comment\">#\u4ece\u8fdc\u7aef\u4ed3\u5e93\u4e0b\u8f7d\u9879\u76ee\u6587\u4ef6\u548c\u7248\u672c\u5386\u53f2&#xff0c;\u5e76\u5728\u5f53\u524d\u76ee\u5f55\u521b\u5efa\u4e00\u4e2a\u672c\u5730\u4ed3\u5e93\u3002<\/span><br \/>\n<span class=\"token comment\"># \u793a\u4f8b<\/span><br \/>\n<span class=\"token function\">git<\/span> clone https:\/\/github.com\/octocat\/Hello-World.git<\/p>\n<p>\u6267\u884c\u540e&#xff0c;\u5f53\u524d\u76ee\u5f55\u901a\u5e38\u4f1a\u51fa\u73b0\u4e00\u4e2a Hello-World \u6587\u4ef6\u5939\u3002<\/p>\n<p>\u6ce8\u610f\u4e8b\u9879&#xff1a;<\/p>\n<ul>\n<li>[url] \u8981\u66ff\u6362\u6210\u81ea\u5df1\u590d\u5236\u7684\u9879\u76ee\u94fe\u63a5\u3002<\/li>\n<li>clone \u4e0d\u53ea\u662f\u4e0b\u8f7d\u5f53\u524d\u6587\u4ef6&#xff0c;\u8fd8\u4f1a\u4e0b\u8f7d Git \u7684\u7248\u672c\u5386\u53f2\u3002<\/li>\n<li>\u6267\u884c\u547d\u4ee4\u524d&#xff0c;\u5e94\u5148\u8fdb\u5165\u5e0c\u671b\u4fdd\u5b58\u9879\u76ee\u7684\u76ee\u5f55\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>6-5 Git \u4e09\u677f\u65a7<\/h4>\n<p>\u624b\u52a8\u4fee\u6539\u6587\u4ef6\u540e&#xff0c;Git \u4e0d\u4f1a\u81ea\u52a8\u628a\u4fee\u6539\u63d0\u4ea4\u5230\u4ed3\u5e93\u3002\u56e0\u4e3a\u6709\u4e9b\u4fee\u6539\u53ef\u80fd\u53ea\u662f\u4e34\u65f6\u5c1d\u8bd5&#xff0c;Git \u9700\u8981\u5148\u8ba9\u4f60\u9009\u62e9\u54ea\u4e9b\u4fee\u6539\u8981\u4fdd\u5b58\u3002<\/p>\n<p>Git \u7684\u57fa\u672c\u6d41\u7a0b\u662f&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u7b2c\u4e00\u677f\u65a7&#xff1a;git add<\/span><br \/>\n<span class=\"token function\">git<\/span> <span class=\"token function\">add<\/span> \u6587\u4ef6\u540d          <span class=\"token comment\"># \u5c06\u6307\u5b9a\u6587\u4ef6\u7684\u4fee\u6539\u653e\u5165\u6682\u5b58\u533a<\/span><br \/>\n<span class=\"token function\">git<\/span> <span class=\"token function\">add<\/span> <span class=\"token builtin class-name\">.<\/span>               <span class=\"token comment\"># \u5c06\u5f53\u524d\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u53d8\u66f4\u653e\u5165\u6682\u5b58\u533a<\/span><\/p>\n<p><span class=\"token comment\"># \u7b2c\u4e8c\u677f\u65a7&#xff1a;git commit<\/span><br \/>\n<span class=\"token function\">git<\/span> commit <span class=\"token parameter variable\">-m<\/span> <span class=\"token string\">&#034;\u65e5\u5fd7&#034;<\/span>    <span class=\"token comment\"># \u5c06\u6682\u5b58\u533a\u5185\u5bb9\u63d0\u4ea4\u5230\u672c\u5730\u4ed3\u5e93&#xff0c;\u5f62\u6210\u65b0\u7684\u7248\u672c<\/span><\/p>\n<p><span class=\"token comment\"># \u7b2c\u4e09\u677f\u65a7&#xff1a;git push<\/span><br \/>\n<span class=\"token function\">git<\/span> push                <span class=\"token comment\"># \u5c06\u672c\u5730\u4ed3\u5e93\u5df2\u63d0\u4ea4\u7684\u7248\u672c\u4e0a\u4f20\u5230\u8fdc\u7a0b\u4ed3\u5e93<\/span><\/p>\n<p>\u6682\u5b58\u533a&#xff1a;\u63d0\u4ea4\u524d\u4e34\u65f6\u653e\u7f6e\u201c\u51c6\u5907\u4fdd\u5b58\u54ea\u4e9b\u4fee\u6539\u201d\u7684\u533a\u57df\u3002<\/p>\n<p>\u6ce8\u610f\u4e8b\u9879&#xff1a;<\/p>\n<ul>\n<li>push \u53ea\u80fd\u4e0a\u4f20\u5df2\u7ecf commit \u7684\u5185\u5bb9&#xff0c;\u4e0d\u80fd\u76f4\u63a5\u4e0a\u4f20\u53ea\u6267\u884c\u4e86 add \u7684\u5185\u5bb9\u3002<\/li>\n<li>\u7b2c\u4e00\u6b21\u63a8\u9001\u65f6&#xff0c;\u53ef\u80fd\u9700\u8981\u767b\u5f55 GitHub&#xff0c;\u6216\u6309\u63d0\u793a\u8bbe\u7f6e\u8fdc\u7aef\u5206\u652f\u3002<\/li>\n<li>push \u6210\u529f\u540e&#xff0c;\u5176\u4ed6\u534f\u4f5c\u8005\u624d\u80fd\u4ece\u8fdc\u7aef\u83b7\u53d6\u4f60\u7684\u63d0\u4ea4\u3002<\/li>\n<\/ul>\n<h5>\u9996\u6b21\u4f7f\u7528\u914d\u7f6e\u7528\u6237\u540d\u548c\u90ae\u7bb1<\/h5>\n<p>Git \u9700\u8981\u77e5\u9053\u6bcf\u6b21\u63d0\u4ea4\u662f\u8c01\u5b8c\u6210\u7684&#xff0c;\u56e0\u6b64\u7b2c\u4e00\u6b21\u4f7f\u7528\u65f6\u8981\u914d\u7f6e\u7528\u6237\u540d\u548c\u90ae\u7bb1\u3002<\/p>\n<p>\u8bed\u6cd5&#xff1a;<\/p>\n<p><span class=\"token function\">git<\/span> config <span class=\"token parameter variable\">&#8211;global<\/span> user.name <span class=\"token string\">&#034;\u7528\u6237\u540d&#034;<\/span><br \/>\n<span class=\"token function\">git<\/span> config <span class=\"token parameter variable\">&#8211;global<\/span> user.email <span class=\"token string\">&#034;\u90ae\u7bb1&#034;<\/span><\/p>\n<p>**\u529f\u80fd&#xff1a;**\u8bbe\u7f6e\u5f53\u524d\u7528\u6237\u7684\u63d0\u4ea4\u8eab\u4efd&#xff1b;&#8211;global \u8868\u793a\u5bf9\u5f53\u524d\u7535\u8111\u4e0a\u7684\u6240\u6709 Git \u9879\u76ee\u751f\u6548\u3002<\/p>\n<p>\u6ce8\u610f\u4e8b\u9879&#xff1a;<\/p>\n<ul>\n<li>\u90ae\u7bb1\u5e94\u586b\u5199\u81ea\u5df1\u4f7f\u7528\u7684\u90ae\u7bb1\u3002<\/li>\n<li>\u8fd9\u53ea\u662f\u8bb0\u5f55\u63d0\u4ea4\u8005\u8eab\u4efd&#xff0c;\u4e0d\u7b49\u540c\u4e8e\u5b8c\u6210 GitHub \u767b\u5f55\u3002<\/li>\n<\/ul>\n<p>\u901a\u5e38\u9700\u8981\u914d\u7f6e\u79c1\u4eba\u4ee4\u724c <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261011181716-6acbd2ac8caa2.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h5>\u7248\u672c\u7ba1\u7406\u53ea\u7ba1\u7406\u6e90\u6587\u4ef6<\/h5>\n<p>\u6e90\u6587\u4ef6&#xff1a;\u7a0b\u5e8f\u5458\u7f16\u5199\u3001\u53ef\u4ee5\u76f4\u63a5\u9605\u8bfb\u548c\u4fee\u6539\u7684\u4ee3\u7801\u6587\u4ef6\u3002\u4f8b\u5982 .cpp\u3001.h\u3001.py \u7b49\u3002<\/p>\n<p>\u7f16\u8bd1\u7a0b\u5e8f\u65f6&#xff0c;\u901a\u5e38\u8fd8\u4f1a\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3001\u4e34\u65f6\u6587\u4ef6\u6216\u7f13\u5b58\u6587\u4ef6\u3002\u8fd9\u4e9b\u6587\u4ef6\u53ef\u4ee5\u7531\u7a0b\u5e8f\u91cd\u65b0\u751f\u6210&#xff0c;\u4e0d\u9700\u8981\u653e\u8fdb\u7248\u672c\u4ed3\u5e93&#xff0c;\u56e0\u6b64\u7248\u672c\u7ba1\u7406\u4e3b\u8981\u4fdd\u5b58\u6e90\u6587\u4ef6\u548c\u5fc5\u8981\u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<p>\u7248\u672c\u7ba1\u7406\u4e3b\u8981\u7ba1\u7406\u6e90\u6587\u4ef6&#xff0c;\u4e0d\u8981\u628a\u53ef\u6267\u884c\u6587\u4ef6\u3001\u4e34\u65f6\u6587\u4ef6\u548c\u7f13\u5b58\u6587\u4ef6\u5168\u90e8\u63d0\u4ea4\u8fdb\u53bb\u3002<\/p>\n<h5>\u4f7f\u7528 .gitignore \u5ffd\u7565\u6587\u4ef6<\/h5>\n<p>\u5982\u679c\u6bcf\u6b21\u6267\u884c git add . \u90fd\u628a\u4e34\u65f6\u6587\u4ef6\u52a0\u5165\u6682\u5b58\u533a&#xff0c;\u5c31\u9700\u8981\u53cd\u590d\u624b\u52a8\u5220\u9664\u3002\u56e0\u6b64&#xff0c;\u53ef\u4ee5\u544a\u8bc9 Git \u54ea\u4e9b\u6587\u4ef6\u4e0d\u8981\u7ba1\u7406\u3002<\/p>\n<p>.gitignore&#xff1a;\u5217\u51fa\u9700\u8981\u88ab Git \u5ffd\u7565\u7684\u6587\u4ef6\u540d\u6216\u6587\u4ef6\u540e\u7f00\u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<p>\u5728\u9879\u76ee\u6839\u76ee\u5f55\u521b\u5efa\u540d\u4e3a .gitignore \u7684\u6587\u4ef6&#xff0c;\u4f8b\u5982&#xff1a;<\/p>\n<p>*.o       # \u5ffd\u7565\u6240\u6709\u4ee5 .o \u7ed3\u5c3e\u7684\u6587\u4ef6<br \/>\n*.out     # \u5ffd\u7565\u6240\u6709\u4ee5 .out \u7ed3\u5c3e\u7684\u6587\u4ef6<br \/>\nbuild\/    # \u5ffd\u7565\u540d\u4e3a build \u7684\u76ee\u5f55<\/p>\n<p>\u6ce8\u610f\u4e8b\u9879&#xff1a;<\/p>\n<ul>\n<li>.gitignore \u672c\u8eab\u901a\u5e38\u5e94\u8be5\u63d0\u4ea4\u5230\u4ed3\u5e93&#xff0c;\u8ba9\u6240\u6709\u534f\u4f5c\u8005\u4f7f\u7528\u540c\u4e00\u5957\u5ffd\u7565\u89c4\u5219\u3002<\/li>\n<li>\u5df2\u7ecf\u88ab Git \u63d0\u4ea4\u8fc7\u7684\u6587\u4ef6&#xff0c;\u540e\u6765\u518d\u5199\u5165 .gitignore&#xff0c;\u4e0d\u4f1a\u81ea\u52a8\u4ece\u5386\u53f2\u4e2d\u6d88\u5931&#xff1b;.gitignore \u4e3b\u8981\u9632\u6b62\u5c1a\u672a\u88ab\u7ba1\u7406\u7684\u6587\u4ef6\u88ab\u52a0\u5165\u3002<\/li>\n<\/ul>\n<p>.gitignore \u7528\u6765\u63d0\u524d\u6392\u9664\u4e0d\u5e94\u8fdb\u5165\u7248\u672c\u4ed3\u5e93\u7684\u6587\u4ef6\u548c\u76ee\u5f55\u3002<\/p>\n<h5>git push \u88ab\u62d2\u7edd\u65f6\u7684\u51b2\u7a81<\/h5>\n<p>\u6709\u65f6\u6267\u884c git push \u4f1a\u51fa\u73b0 rejected\u3002\u8fd9\u901a\u5e38\u8868\u793a&#xff1a;\u8fdc\u7aef\u4ed3\u5e93\u5df2\u7ecf\u6709\u4e86\u672c\u5730\u6ca1\u6709\u7684\u66f4\u65b0\u3002<\/p>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>\u8fdc\u7aef\u4ed3\u5e93&#xff1a;A \u2014\u2014 B<br \/>\n\u672c\u5730\u4ed3\u5e93&#xff1a;A \u2014\u2014 C<\/p>\n<p>\u56e0\u4e3a\u8fdc\u7aef\u6bd4\u672c\u5730\u66f4\u65b0&#xff0c;\u5982\u679c\u76f4\u63a5\u63a8\u9001&#xff0c;Git \u4e0d\u77e5\u9053\u5982\u4f55\u5b89\u5168\u5730\u8986\u76d6\u8fdc\u7aef\u5185\u5bb9&#xff0c;\u6240\u4ee5\u62d2\u7edd\u64cd\u4f5c\u3002<\/p>\n<p>\u89e3\u51b3\u6d41\u7a0b&#xff1a;<\/p>\n<p><span class=\"token function\">git<\/span> pull  <span class=\"token comment\">#\u4ece\u8fdc\u7aef\u83b7\u53d6\u6700\u65b0\u5185\u5bb9&#xff0c;\u5e76\u5c1d\u8bd5\u5408\u5e76\u5230\u5f53\u524d\u672c\u5730\u5206\u652f\u3002<\/span><br \/>\n<span class=\"token function\">git<\/span> push<\/p>\n<p>\u5982\u679c\u4e24\u8fb9\u4fee\u6539\u4e86\u540c\u4e00\u4f4d\u7f6e&#xff0c;\u53ef\u80fd\u4ea7\u751f\u51b2\u7a81\u3002\u51b2\u7a81\u5c31\u662f Git \u65e0\u6cd5\u81ea\u52a8\u5224\u65ad\u5e94\u8be5\u4fdd\u7559\u54ea\u4e00\u4efd\u4fee\u6539&#xff0c;\u9700\u8981\u624b\u52a8\u4fee\u6539\u6587\u4ef6\u540e&#xff0c;\u518d\u6267\u884c git add\u3001git commit \u548c git push\u3002<\/p>\n<p>\u8fdc\u7aef\u6bd4\u672c\u5730\u65b0\u65f6&#xff0c;\u5148\u7528 git pull \u540c\u6b65&#xff0c;\u518d\u7528 git push \u4e0a\u4f20\u3002<\/p>\n<h5>\u5176\u4ed6\u5e38\u7528\u547d\u4ee4<\/h5>\n<p>git status                    # \u67e5\u770b\u5f53\u524d\u4ed3\u5e93\u72b6\u6001&#xff1a;\u4fee\u6539\u3001\u6682\u5b58\u3001\u672a\u8ddf\u8e2a\u7b49<\/p>\n<p>git log                       # \u67e5\u770b\u672c\u5730\u4ed3\u5e93\u7684\u63d0\u4ea4\u5386\u53f2<\/p>\n<p>git pull                      # \u83b7\u53d6\u8fdc\u7a0b\u4ed3\u5e93\u7684\u65b0\u63d0\u4ea4&#xff0c;\u5e76\u5408\u5e76\u5230\u5f53\u524d\u5206\u652f<\/p>\n<p># \u57fa\u672c\u63d0\u4ea4\u6d41\u7a0b<br \/>\ngit status                    # \u63d0\u4ea4\u524d\u68c0\u67e5\u4ed3\u5e93\u72b6\u6001<br \/>\ngit add main.cpp              # \u5c06\u4fee\u6539\u653e\u5165\u6682\u5b58\u533a<br \/>\ngit commit -m &#034;\u5b8c\u6210\u4e3b\u8981\u529f\u80fd&#034;   # \u5c06\u6682\u5b58\u533a\u5185\u5bb9\u63d0\u4ea4\u5230\u672c\u5730\u4ed3\u5e93<br \/>\ngit push                      # \u5c06\u672c\u5730\u63d0\u4ea4\u4e0a\u4f20\u5230\u8fdc\u7a0b\u4ed3\u5e93<\/p>\n<p># \u5982\u679c push \u88ab\u62d2\u7edd&#xff0c;\u901a\u5e38\u5148\u540c\u6b65\u8fdc\u7a0b\u4ed3\u5e93<br \/>\ngit pull                      # \u83b7\u53d6\u5e76\u5408\u5e76\u8fdc\u7a0b\u7684\u65b0\u63d0\u4ea4<br \/>\ngit push                      # \u518d\u6b21\u63a8\u9001\u672c\u5730\u63d0\u4ea4<\/p>\n<hr \/>\n<h3>\u603b\u7ed3&#xff1a;6. \u7248\u672c\u63a7\u5236\u5668 Git<\/h3>\n<h4>\u6838\u5fc3\u6982\u5ff5<\/h4>\n<ul>\n<li>\u7248\u672c\u63a7\u5236\u5668\u4e24\u5927\u4ef7\u503c&#xff1a;\u6570\u636e\u5b89\u5168&#xff08;\u6539\u9519\u53ef\u627e\u56de&#xff09;&#043; \u534f\u4f5c\u5f00\u53d1&#xff08;\u8bb0\u5f55\u8c01\u6539\u4e86\u4ec0\u4e48&#xff09;\u3002\u3010\u91cd\u70b9\u3011<\/li>\n<li>\u4ed3\u5e93 &#061; \u9879\u76ee\u6587\u4ef6 &#043; \u5b8c\u6574\u4fee\u6539\u8bb0\u5f55&#xff1b;\u672c\u5730\u4ed3\u5e93&#xff08;\u81ea\u5df1\u7535\u8111&#xff09;vs \u8fdc\u7aef\u4ed3\u5e93&#xff08;\u4e91\u7aef&#xff0c;\u5171\u4eab\u5907\u4efd&#xff09;\u3002<\/li>\n<li>Git \u662f\u5206\u5e03\u5f0f&#xff1a;\u6bcf\u4e2a\u672c\u5730\u4ed3\u5e93\u90fd\u6709\u5b8c\u6574\u5386\u53f2&#xff0c;\u65ad\u7f51\u4e5f\u80fd\u672c\u5730\u63d0\u4ea4\u3002<\/li>\n<li>GitHub\/Gitee \u662f\u57fa\u4e8e Git \u7684\u5e73\u53f0&#xff0c;\u2260 Git \u672c\u8eab\u3002\u3010\u6613\u6df7\u3011<\/li>\n<li>\u9996\u6b21\u4f7f\u7528\u914d\u8eab\u4efd&#xff1a;git config &#8211;global user.name &#034;\u540d&#034; &#043; user.email &#034;\u90ae\u7bb1&#034;\u3002<\/li>\n<\/ul>\n<h4>\u4e09\u677f\u65a7\u3010\u91cd\u70b9\u3011<\/h4>\n<p><span class=\"token function\">git<\/span> <span class=\"token function\">add<\/span> main.cpp             <span class=\"token comment\"># \u2460 \u4fee\u6539 \u2192 \u6682\u5b58\u533a&#xff08;git add . \u6682\u5b58\u5168\u90e8&#xff0c;\u614e\u7528&#xff09;<\/span><br \/>\n<span class=\"token function\">git<\/span> commit <span class=\"token parameter variable\">-m<\/span> <span class=\"token string\">&#034;\u4fee\u590d\u767b\u5f55\u9519\u8bef&#034;<\/span>  <span class=\"token comment\"># \u2461 \u6682\u5b58\u533a \u2192 \u672c\u5730\u4ed3\u5e93&#xff08;-m \u5199\u6e05\u505a\u4e86\u4ec0\u4e48&#xff1b;\u53ea\u63d0\u4ea4\u53d8\u5316\u90e8\u5206&#xff09;<\/span><br \/>\n<span class=\"token function\">git<\/span> push                     <span class=\"token comment\"># \u2462 \u672c\u5730\u4ed3\u5e93 \u2192 \u8fdc\u7aef\u4ed3\u5e93<\/span><\/p>\n<p>\u6d41\u7a0b\u8bb0\u5fc6&#xff1a;\u5de5\u4f5c\u76ee\u5f55 \u2192(add)\u2192 \u6682\u5b58\u533a \u2192(commit)\u2192 \u672c\u5730\u4ed3\u5e93 \u2192(push)\u2192 \u8fdc\u7aef\u4ed3\u5e93\u3002 push \u53ea\u80fd\u4f20 commit \u8fc7\u7684\u5185\u5bb9&#xff1b;\u53ea add \u6ca1 commit \u7684\u5185\u5bb9\u4f20\u4e0d\u4e0a\u53bb\u3002<\/p>\n<h4>\u8f85\u52a9\u547d\u4ee4\u4e0e .gitignore<\/h4>\n<ul>\n<li>git status&#xff08;add\/commit \u524d\u67e5\u72b6\u6001&#xff09;\u3001git log&#xff08;\u770b\u63d0\u4ea4\u5386\u53f2&#xff09;\u3001git pull&#xff08;\u62c9\u8fdc\u7aef\u5e76\u5408\u5e76&#xff09;\u3002<\/li>\n<li>push \u88ab\u62d2\u7edd&#xff08;rejected&#xff09;&#061; \u8fdc\u7aef\u6bd4\u672c\u5730\u65b0 \u2192 \u5148 git pull \u540c\u6b65&#xff0c;\u518d git push&#xff1b;\u540c\u4e00\u4f4d\u7f6e\u4e24\u8fb9\u90fd\u6539 &#061; \u51b2\u7a81&#xff0c;\u624b\u52a8\u6539\u5b8c\u540e\u91cd\u65b0 add\/commit\/push\u3002\u3010\u91cd\u70b9\u3011<\/li>\n<li>.gitignore&#xff1a;\u5217\u51fa\u8981\u5ffd\u7565\u7684\u6587\u4ef6\/\u540e\u7f00\/\u76ee\u5f55&#xff08;*.o\u3001build\/&#xff09;&#xff1b;\u53ea\u7ba1\u7406\u6e90\u6587\u4ef6&#xff0c;\u53ef\u6267\u884c\u6587\u4ef6\/\u4e34\u65f6\u6587\u4ef6\u4e0d\u8fdb\u4ed3\u5e93\u3002<\/li>\n<li>.gitignore \u672c\u8eab\u5e94\u63d0\u4ea4&#xff1b;\u5df2\u88ab\u7ba1\u7406\u8fc7\u7684\u6587\u4ef6\u518d\u52a0\u5165 .gitignore \u4e0d\u4f1a\u4ece\u5386\u53f2\u6d88\u5931\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3>7. \u8c03\u8bd5\u5668 gdb\/cgdb<\/h3>\n<h4>cgdb<\/h4>\n<p>\u5efa\u8bae\u4f7f\u7528cgdb&#xff0c;\u4e24\u8005\u547d\u4ee4\u5b8c\u5168\u4e0d\u53d8<\/p>\n<ul>\n<li>\u5206\u5c4f\u53ef\u89c6\u5316\u7248 gdb&#xff0c;\u547d\u4ee4\u5b8c\u5168\u4e0d\u53d8&#xff1b;yum\/apt install -y cgdb \u5b89\u88c5&#xff1b;ESC \u8fdb\u4ee3\u7801\u5c4f&#xff0c;i \u56de\u547d\u4ee4\u5c4f\u3002<\/li>\n<\/ul>\n<h4>\u9884\u5907&#xff1a;\u5fc5\u987b\u5148 -g\u3010\u91cd\u70b9\u3011<\/h4>\n<ul>\n<li>debug&#xff08;\u6d4b\u8bd5\u7528&#xff0c;\u5e26\u8c03\u8bd5\u4fe1\u606f&#xff09;vs release&#xff08;\u4e0a\u7ebf\u7528&#xff0c;\u65e0\u8c03\u8bd5\u4fe1\u606f&#xff09;\u3002<\/li>\n<li>gcc\/g&#043;&#043; \u9ed8\u8ba4\u7f16\u8bd1 release&#xff0c;\u65e0\u6cd5\u6e90\u7801\u7ea7\u8c03\u8bd5 \u2192 \u5fc5\u987b gcc -g mycmd.c -o mycmd\u3002<\/li>\n<li>\u9a8c\u8bc1&#xff1a;file mycmd \u770b with debug_info&#xff1b;\u6216 readelf -S mycmd | grep -i debug \u770b .debug_info \u6bb5\u3002<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261011181717-6acbd2add31a5.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261011181718-6acbd2aeb2ccb.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u5f00\u59cb&#xff1a;gdb binFile<\/li>\n<li>\u9000\u51fa&#xff1a;ctrl &#043; d \u6216 quit<\/li>\n<\/ul>\n<h4>gdb\u547d\u4ee4\u5408\u96c6\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f<\/h4>\n<table>\n<tr>\u8c03\u8bd5\u547d\u4ee4\u4f5c\u7528\u6837\u4f8b<\/tr>\n<tbody>\n<tr>\n<td>list\/l<\/td>\n<td>\u663e\u793a\u6e90\u4ee3\u7801&#xff0c;\u4ece\u4e0a\u6b21\u4f4d\u7f6e\u5f00\u59cb&#xff0c;\u6bcf\u6b21\u5217\u51fa 10 \u884c<\/td>\n<td>list\/l 10<\/td>\n<\/tr>\n<tr>\n<td>list\/l \u51fd\u6570\u540d<\/td>\n<td>\u5217\u51fa\u6307\u5b9a\u51fd\u6570\u7684\u6e90\u4ee3\u7801<\/td>\n<td>list\/l main<\/td>\n<\/tr>\n<tr>\n<td>list\/l \u6587\u4ef6\u540d:\u884c\u53f7<\/td>\n<td>\u5217\u51fa\u6307\u5b9a\u6587\u4ef6\u7684\u6e90\u4ee3\u7801<\/td>\n<td>list\/l mycmd.c:1<\/td>\n<\/tr>\n<tr>\n<td>r\/run<\/td>\n<td>\u4ece\u7a0b\u5e8f\u5f00\u59cb\u8fde\u7eed\u6267\u884c<\/td>\n<td>run<\/td>\n<\/tr>\n<tr>\n<td>n\/next<\/td>\n<td>\u5355\u6b65\u6267\u884c&#xff0c;\u4e0d\u8fdb\u5165\u51fd\u6570\u5185\u90e8&#xff0c;\u9010\u8fc7\u7a0b F10<\/td>\n<td>next<\/td>\n<\/tr>\n<tr>\n<td>s\/step<\/td>\n<td>\u5355\u6b65\u6267\u884c&#xff0c;\u8fdb\u5165\u51fd\u6570\u5185\u90e8&#xff0c;\u9010\u8bed\u53e5 F11<\/td>\n<td>step<\/td>\n<\/tr>\n<tr>\n<td>break\/b [\u6587\u4ef6\u540d:]\u884c\u53f7<\/td>\n<td>\u5728\u6307\u5b9a\u884c\u53f7\u8bbe\u7f6e\u65ad\u70b9<\/td>\n<td>break 10break test.c:10<\/td>\n<\/tr>\n<tr>\n<td>break\/b \u51fd\u6570\u540d<\/td>\n<td>\u5728\u51fd\u6570\u5f00\u5934\u8bbe\u7f6e\u65ad\u70b9<\/td>\n<td>break main<\/td>\n<\/tr>\n<tr>\n<td>info break\/b<\/td>\n<td>\u67e5\u770b\u5f53\u524d\u6240\u6709\u65ad\u70b9\u7684\u4fe1\u606f<\/td>\n<td>info break<\/td>\n<\/tr>\n<tr>\n<td>finish<\/td>\n<td>\u6267\u884c\u5230\u5f53\u524d\u51fd\u6570\u8fd4\u56de&#xff0c;\u7136\u540e\u505c\u6b62<\/td>\n<td>finish<\/td>\n<\/tr>\n<tr>\n<td>print\/p \u8868\u8fbe\u5f0f<\/td>\n<td>\u6253\u5370\u8868\u8fbe\u5f0f\u7684\u503c<\/td>\n<td>print start&#043;end<\/td>\n<\/tr>\n<tr>\n<td>p \u53d8\u91cf<\/td>\n<td>\u6253\u5370\u6307\u5b9a\u53d8\u91cf\u7684\u503c<\/td>\n<td>p x<\/td>\n<\/tr>\n<tr>\n<td>set var \u53d8\u91cf&#061;\u503c<\/td>\n<td>\u4fee\u6539\u53d8\u91cf\u7684\u503c<\/td>\n<td>set var i&#061;10<\/td>\n<\/tr>\n<tr>\n<td>continue\/c<\/td>\n<td>\u4ece\u5f53\u524d\u4f4d\u7f6e\u5f00\u59cb\u8fde\u7eed\u6267\u884c\u7a0b\u5e8f<\/td>\n<td>continue<\/td>\n<\/tr>\n<tr>\n<td>delete\/d breakpoints<\/td>\n<td>\u5220\u9664\u6240\u6709\u65ad\u70b9<\/td>\n<td>delete breakpoints<\/td>\n<\/tr>\n<tr>\n<td>delete\/d breakpoints n<\/td>\n<td>\u5220\u9664\u5e8f\u53f7\u4e3a n \u7684\u65ad\u70b9<\/td>\n<td>delete breakpoints 1<\/td>\n<\/tr>\n<tr>\n<td>disable breakpoints<\/td>\n<td>\u7981\u7528\u6240\u6709\u65ad\u70b9<\/td>\n<td>disable breakpoints<\/td>\n<\/tr>\n<tr>\n<td>enable breakpoints<\/td>\n<td>\u542f\u7528\u6240\u6709\u65ad\u70b9<\/td>\n<td>enable breakpoints<\/td>\n<\/tr>\n<tr>\n<td>info\/i breakpoints<\/td>\n<td>\u67e5\u770b\u5f53\u524d\u8bbe\u7f6e\u7684\u65ad\u70b9\u5217\u8868<\/td>\n<td>info breakpoints<\/td>\n<\/tr>\n<tr>\n<td>display \u53d8\u91cf\u540d<\/td>\n<td>\u8ddf\u8e2a\u663e\u793a\u6307\u5b9a\u53d8\u91cf\u7684\u503c&#xff08;\u6bcf\u6b21\u505c\u6b62\u65f6&#xff09;<\/td>\n<td>display x<\/td>\n<\/tr>\n<tr>\n<td>undisplay \u7f16\u53f7<\/td>\n<td>\u53d6\u6d88\u5bf9\u6307\u5b9a\u7f16\u53f7\u7684\u53d8\u91cf\u7684\u8ddf\u8e2a\u663e\u793a<\/td>\n<td>undisplay 1<\/td>\n<\/tr>\n<tr>\n<td>until X \u884c\u53f7<\/td>\n<td>\u6267\u884c\u5230\u6307\u5b9a\u884c\u53f7<\/td>\n<td>until 20<\/td>\n<\/tr>\n<tr>\n<td>backtrace\/bt<\/td>\n<td>\u67e5\u770b\u5f53\u524d\u6267\u884c\u6808\u7684\u5404\u7ea7\u51fd\u6570\u8c03\u7528\u53ca\u53c2\u6570<\/td>\n<td>backtrace<\/td>\n<\/tr>\n<tr>\n<td>info\/i locals<\/td>\n<td>\u67e5\u770b\u5f53\u524d\u6808\u5e27\u7684\u5c40\u90e8\u53d8\u91cf\u503c<\/td>\n<td>info locals<\/td>\n<\/tr>\n<tr>\n<td>quit<\/td>\n<td>\u9000\u51fa GDB \u8c03\u8bd5\u5668<\/td>\n<td>quit<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u5e38\u7528\u547d\u4ee4\u901f\u67e5<\/h4>\n<table>\n<tr>\u547d\u4ee4\u529f\u80fd<\/tr>\n<tbody>\n<tr>\n<td>gdb \u7a0b\u5e8f\u540d \/ quit \u6216 ctrl&#043;d<\/td>\n<td>\u8fdb\u5165 \/ \u9000\u51fa<\/td>\n<\/tr>\n<tr>\n<td>l&#xff08;list&#xff09; \/ r&#xff08;run&#xff09;<\/td>\n<td>\u770b\u6e90\u7801 \/ \u8fd0\u884c\u5230\u65ad\u70b9\u6216\u7ed3\u675f<\/td>\n<\/tr>\n<tr>\n<td>b \u884c\u53f7 \/ b \u51fd\u6570\u540d \/ info b<\/td>\n<td>\u8bbe\u65ad\u70b9 \/ \u770b\u65ad\u70b9<\/td>\n<\/tr>\n<tr>\n<td>n \/ s \/ finish<\/td>\n<td>\u9010\u8fc7\u7a0b \/ \u9010\u8bed\u53e5 \/ \u6267\u884c\u5230\u51fd\u6570\u8fd4\u56de<\/td>\n<\/tr>\n<tr>\n<td>p \u53d8\u91cf \/ set var \u53d8\u91cf&#061;\u503c<\/td>\n<td>\u6253\u5370 \/ \u73b0\u573a\u6539\u503c&#xff08;\u4e0d\u6539\u6e90\u7801&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>c \/ until \u884c\u53f7<\/td>\n<td>\u7ee7\u7eed\u5230\u4e0b\u4e00\u65ad\u70b9 \/ \u6267\u884c\u5230\u6307\u5b9a\u884c<\/td>\n<\/tr>\n<tr>\n<td>d \u7f16\u53f7 \/ disable \u7f16\u53f7 \/ enable \u7f16\u53f7<\/td>\n<td>\u5220 \/ \u7981\u7528 \/ \u542f\u7528\u65ad\u70b9<\/td>\n<\/tr>\n<tr>\n<td>display \u53d8\u91cf \/ undisplay \u7f16\u53f7<\/td>\n<td>\u6bcf\u6b21\u505c\u4e0b\u81ea\u52a8\u663e\u793a \/ \u53d6\u6d88<\/td>\n<\/tr>\n<tr>\n<td>bt \/ info locals<\/td>\n<td>\u770b\u8c03\u7528\u6808 \/ \u770b\u5f53\u524d\u51fd\u6570\u5c40\u90e8\u53d8\u91cf<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u65ad\u70b9\u7f16\u53f7\u53ea\u589e\u4e0d\u51cf&#xff08;\u5220\u4e86 2 \u518d\u8bbe\u65b0\u7684\u4e0d\u4f1a\u8865\u56de 2&#xff09;&#xff1b;\u2191 \u91cd\u590d\u4e0a\u4e00\u6761\u547d\u4ee4&#xff1b;undisplay \u8ddf\u7684\u662f\u663e\u793a\u7f16\u53f7\u4e0d\u662f\u53d8\u91cf\u540d\u3002\u53ea\u6709\u65b0\u589e\u65ad\u70b9\u65f6\u4f1a\u7528\u5230\u884c\u53f7&#xff0c;\u5176\u4ed6\u60c5\u51b5\u90fd\u662f\u4f7f\u7528\u65ad\u70b9\u7f16\u53f7&#xff01;<\/p>\n<h4>\u4e09\u4e2a\u8c03\u8bd5\u6280\u5de7\u3010\u91cd\u70b9\u3011<\/h4>\n<li>watch \u53d8\u91cf&#xff1a;\u503c\u4e00\u53d8\u5c31\u6682\u505c\u5e76\u663e\u793a\u65b0\u65e7\u503c \u2014\u2014 \u67e5&#034;\u53d8\u91cf\u5728\u54ea\u4e00\u523b\u88ab\u6539\u4e86&#034;\u3002<\/li>\n<li>set var \u53d8\u91cf&#061;\u503c&#xff1a;\u73b0\u573a\u6539\u503c\u9a8c\u8bc1\u731c\u60f3 \u2014\u2014 \u4e0d\u91cd\u7f16\u8bd1&#xff0c;\u53ea\u6539\u672c\u6b21\u8fd0\u884c\u3002<\/li>\n<li>\u6761\u4ef6\u65ad\u70b9&#xff1a;<\/li>\n<table>\n<tr>\u76ee\u7684\u8bed\u6cd5\u6709 if \u5417<\/tr>\n<tbody>\n<tr>\n<td>\u65b0\u589e\u6761\u4ef6\u65ad\u70b9<\/td>\n<td>b 9 if i&#061;&#061;30<\/td>\n<td>\u6709 if<\/td>\n<\/tr>\n<tr>\n<td>\u7ed9\u5df2\u6709\u65ad\u70b9\u52a0\u6761\u4ef6<\/td>\n<td>condition 2 i&#061;&#061;30<\/td>\n<td>\u6ca1\u6709 if&#xff0c;2 \u662f\u65ad\u70b9\u7f16\u53f7<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>cgdb\u7a97\u53e3\u4e4b\u95f4\u8f6c\u6362&#xff0c; ESC\u8fdb\u5165\u4ee3\u7801\u533a&#xff0c;\u4e0a\u9762\u7a97\u53e3 i&#xff0c;\u8fdb\u5165cgdb\u4e0b\u9762\u7a97\u53e3<\/p>\n<hr \/>\n<h3>8. \u9644\u5f55&#xff1a;\u6362\u6e90\u5b9e\u64cd<\/h3>\n<h4>\u6b65\u9aa4\u4e3b\u7ebf&#xff08;\u4e24\u8005\u4e00\u81f4&#xff09;<\/h4>\n<p>\u5907\u4efd \u2192 \u4e0b\u8f7d\/\u66ff\u6362\u65b0\u6e90\u914d\u7f6e \u2192 \u6e05\u7f13\u5b58\u66f4\u65b0 \u2192&#xff08;\u53ef\u9009\u5347\u7ea7&#xff09;\u2192 \u9a8c\u8bc1 \u2192&#xff08;\u53ef\u9009\u6062\u590d&#xff09;<\/p>\n<h4>CentOS 7 \u6362 yum \u6e90<\/h4>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">mkdir<\/span> \/etc\/yum.repos.d\/backup                          <span class=\"token comment\"># \u2460 \u5efa\u5907\u4efd\u76ee\u5f55<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">mv<\/span> \/etc\/yum.repos.d\/*.repo \/etc\/yum.repos.d\/backup\/    <span class=\"token comment\"># \u2461 \u5907\u4efd\u5168\u90e8\u65e7\u6e90<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">curl<\/span> <span class=\"token parameter variable\">-o<\/span> \/etc\/yum.repos.d\/CentOS-Base.repo http:\/\/mirrors.aliyun.com\/repo\/Centos-7.repo  <span class=\"token comment\"># \u2462 \u4e0b\u8f7d\u963f\u91cc\u4e91\u6e90&#xff08;\u6e05\u534e\u6e90\u4e8c\u9009\u4e00&#xff09;<\/span><br \/>\n<span class=\"token function\">sudo<\/span> yum clean all <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token function\">sudo<\/span> yum makecache                    <span class=\"token comment\"># \u2463 \u6e05\u65e7\u7f13\u5b58 &#043; \u91cd\u5efa\u3010\u91cd\u70b9&#xff1a;\u7f3a\u8fd9\u6b65\u4ecd\u8d70\u65e7\u6e90\u3011<\/span><br \/>\n<span class=\"token function\">sudo<\/span> yum update                                             <span class=\"token comment\"># \u2464 \u66f4\u65b0\u7cfb\u7edf<\/span><br \/>\n<span class=\"token function\">sudo<\/span> yum repolist                                           <span class=\"token comment\"># \u2465 \u9a8c\u8bc1<\/span><br \/>\n<span class=\"token comment\"># \u6062\u590d&#xff1a;sudo mv \/etc\/yum.repos.d\/backup\/*.repo \/etc\/yum.repos.d\/<\/span><\/p>\n<h4>Ubuntu \u6362 apt \u6e90<\/h4>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">cp<\/span> \/etc\/apt\/sources.list \/etc\/apt\/sources.list.bak     <span class=\"token comment\"># \u2460 \u5907\u4efd&#xff08;apt \u662f\u5355\u4e2a\u6587\u4ef6&#xff09;<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">wget<\/span> <span class=\"token parameter variable\">-O<\/span> \/etc\/apt\/sources.list http:\/\/mirrors.aliyun.com\/repo\/ubuntu-sources.list  <span class=\"token comment\"># \u2461 \u66ff\u6362&#xff08;\u4e8c\u9009\u4e00&#xff09;<\/span><br \/>\n<span class=\"token comment\"># \u2462 \u68c0\u67e5\u6bcf\u884c\u90fd\u542b focal&#xff08;Ubuntu 20.04 \u4ee3\u53f7&#xff09;&#xff0c;\u6df7\u5165 bionic\/jammy \u8981\u5220\u3010\u6613\u9519\u3011<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> update                                             <span class=\"token comment\"># \u2463 \u66f4\u65b0\u7f13\u5b58<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> policy                                             <span class=\"token comment\"># \u2464 \u9a8c\u8bc1<\/span><br \/>\n<span class=\"token comment\"># \u6062\u590d&#xff1a;sudo cp \/etc\/apt\/sources.list.bak \/etc\/apt\/sources.list &amp;&amp; sudo apt update<\/span><\/p>\n<p>\u3010\u6613\u6df7\u3011 yum \u6e90 &#061; \/etc\/yum.repos.d\/ \u76ee\u5f55\u4e0b\u591a\u4e2a .repo \u6587\u4ef6&#xff1b;apt \u6e90 &#061; \/etc\/apt\/sources.list \u5355\u4e2a\u6587\u4ef6\u3002<\/p>\n<hr \/>\n<h3>\u6613\u6df7\u6dc6\u5bf9\u6bd4\u901f\u67e5\u5361<\/h3>\n<table>\n<tr>\u4e3b\u9898AB<\/tr>\n<tbody>\n<tr>\n<td>\u94fe\u63a5\u65b9\u5f0f<\/td>\n<td>\u52a8\u6001&#xff1a;\u8fd0\u884c\u65f6\u52a0\u8f7d .so&#xff0c;gcc \u9ed8\u8ba4<\/td>\n<td>\u9759\u6001&#xff1a;\u590d\u5236\u8fdb\u7a0b\u5e8f .a&#xff0c;\u9700 -static<\/td>\n<\/tr>\n<tr>\n<td>vim \u64a4\u9500<\/td>\n<td>u \u64a4\u9500&#xff08;\u540e\u9000&#xff09;<\/td>\n<td>ctrl&#043;r \u6062\u590d&#xff08;\u524d\u8fdb&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u56de\u8f66\u6362\u884c<\/td>\n<td>\\\\r \u56de\u884c\u9996<\/td>\n<td>\\\\n \u4e0b\u4e00\u884c<\/td>\n<\/tr>\n<tr>\n<td>gdb \u6b65\u8fdb<\/td>\n<td>n \u4e0d\u8fdb\u51fd\u6570&#xff08;F10&#xff09;<\/td>\n<td>s \u8fdb\u51fd\u6570&#xff08;F11&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u6761\u4ef6\u65ad\u70b9<\/td>\n<td>\u65b0\u589e b 9 if i&#061;&#061;30&#xff08;\u6709 if&#xff09;<\/td>\n<td>\u8ffd\u52a0 condition 2 i&#061;&#061;30&#xff08;\u65e0 if&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u81ea\u52a8\u53d8\u91cf<\/td>\n<td>$&#064; \u76ee\u6807 \/ $&lt; \u7b2c\u4e00\u4e2a\u4f9d\u8d56<\/td>\n<td>$^ \u5168\u90e8\u4f9d\u8d56<\/td>\n<\/tr>\n<tr>\n<td>\u5b89\u88c5\u6e90<\/td>\n<td>base \u6807\u51c6\u7a33\u5b9a<\/td>\n<td>epel \u6269\u5c55\u6c42\u5168<\/td>\n<\/tr>\n<tr>\n<td>\u8f6f\u4ef6\u6e90\u914d\u7f6e<\/td>\n<td>yum&#xff1a;.repo \u76ee\u5f55<\/td>\n<td>apt&#xff1a;sources.list \u5355\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>make \u65f6\u95f4<\/td>\n<td>Modify \u5185\u5bb9\u4fee\u6539&#xff08;make \u770b\u8fd9\u4e2a&#xff09;<\/td>\n<td>Change \u5c5e\u6027\u53d8\u5316 \/ Access \u8bbf\u95ee<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u4e0b\u671f\u9884\u544a<\/h3>\n<h3>\u7ebf\u7a0b<\/h3>\n<h3>\u7ed3\u8bed<\/h3>\n<p>\u2003\u2003\u672c\u6587\u5230\u6b64\u7ed3\u675f&#xff0c;\u611f\u8c22\u5927\u5bb6\u7684\u9605\u8bfb&#xff01;\u5982\u679c\u89c9\u5f97\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9&#xff0c;\u6b22\u8fce\u70b9\u8d5e\u3001\u6536\u85cf\u3001\u5173\u6ce8&#xff0c;\u4e5f\u6b22\u8fce\u5728\u8bc4\u8bba\u533a\u4e00\u8d77\u4ea4\u6d41\u8ba8\u8bba\u3002 \u2003\u2003\u4e5f\u6b22\u8fce\u8ba2\u9605\u6211\u7684 \u6df1\u5165\u7406\u89e3 C&#043;&#043;\u7cfb\u5217&#xff1a;\u4ece\u8bed\u6cd5\u5165\u95e8\u5230\u5e95\u5c42\u539f\u7406&#xff0c;\u7cfb\u7edf\u638c\u63e1\u73b0\u4ee3 C&#043;&#043; \u7b97\u6cd5\u7cfb\u5217&#xff1a;\u4ece\u5165\u95e8\u5230\u7cbe\u901a&#xff0c;\u84dd\u6865\u676f\u3001ACM\u3001LeetCode \u4e0e\u9762\u8bd5\u7b97\u6cd5\u5168\u8def\u7ebf \u5feb\u901f\u590d\u4e60\u7cfb\u5217&#xff1a;\u77e5\u8bc6\u68b3\u7406\u3001\u67e5\u6f0f\u8865\u7f3a&#xff0c;\u8003\u524d\u51b2\u523a\u5fc5\u5907 Linux\u7cfb\u5217&#xff1a;\u4ece\u96f6\u5e26\u4f60\u7cfb\u7edf\u5b66\u4e60Linux\u7cfb\u7edf&#xff0c;\u6df1\u5165\u7406\u89e3\u8ba1\u7b97\u673a\u7ec4\u6210\u539f\u7406&#xff01;<\/p>\n<hr \/>\n<p> <font color=\"#ff4d4f\"><b>\u2003\u2003\u613f\u6bcf\u4e00\u6b21\u6572\u4e0b\u952e\u76d8&#xff0c;\u90fd\u6bd4\u6628\u5929\u66f4\u8fdb\u4e00\u6b65&#xff01;<\/b><\/font> <\/p>\n<p> <font color=\"#ff4d4f\"><b>\u2003\u2003\u613f\u6bcf\u4e00\u884c\u4ee3\u7801\u843d\u4e0b&#xff0c;\u90fd\u8ba9\u672a\u6765\u591a\u4e00\u79cd\u53ef\u80fd&#xff01;<\/b><\/font> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u2b50\ufe0f\u535a\u4e3b&#xff1a;  \u6b64\u751f\u51b3int-CSDN\u535a\u5ba2 \u901f\u80dc\u6d3e\u5c31\u662f\u6700\u5927\u7684\u6295\u964d\u6d3e&#xff01;&#xff01;&#xff01; &#x1f525;\u70ed\u95e8\u4e13\u680f&#x1f525; \u6df1\u5165\u7406\u89e3 C \u7cfb\u5217 &#xff5c; \u7b97\u6cd5\u7cfb\u5217 \u5feb\u901f\u590d\u4e60\u7cfb\u5217 &#xff5c; Linux\u7cfb\u5217<br \/>\nGitee\u5730\u5740&#xff1a;\u8d22\u54e5 | GitHub\u5730\u5740&#xff1a;\u8d22\u54e5 \u6587\u7ae0\u76ee\u5f55\u4e0a\u671f\u56de\u987e4. \u81ea\u52a8\u5316\u6784\u5efa&#xff1a;make \/ Makefile\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f4-1 \u80cc\u666f\u624b\u52a8\u7f16\u8bd1\u9047\u5230\u7684\u95ee\u9898mak<\/p>\n","protected":false},"author":2,"featured_media":115371,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[12392,58,1802,43],"topic":[],"class_list":["post-115377","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-12392","tag-linux","tag-vim","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux\u7cfb\u5217\uff0805\uff09\u2014\u2014\u57fa\u7840\u5f00\u53d1\u5de5\u5177\uff08\u4e0b\uff09makefile\u3001git\u3001gdb - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/115377.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux\u7cfb\u5217\uff0805\uff09\u2014\u2014\u57fa\u7840\u5f00\u53d1\u5de5\u5177\uff08\u4e0b\uff09makefile\u3001git\u3001gdb - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u2b50\ufe0f\u535a\u4e3b&#xff1a; \u6b64\u751f\u51b3int-CSDN\u535a\u5ba2 \u901f\u80dc\u6d3e\u5c31\u662f\u6700\u5927\u7684\u6295\u964d\u6d3e&#xff01;&#xff01;&#xff01; &#x1f525;\u70ed\u95e8\u4e13\u680f&#x1f525; \u6df1\u5165\u7406\u89e3 C \u7cfb\u5217 &#xff5c; \u7b97\u6cd5\u7cfb\u5217 \u5feb\u901f\u590d\u4e60\u7cfb\u5217 &#xff5c; Linux\u7cfb\u5217 Gitee\u5730\u5740&#xff1a;\u8d22\u54e5 | GitHub\u5730\u5740&#xff1a;\u8d22\u54e5 \u6587\u7ae0\u76ee\u5f55\u4e0a\u671f\u56de\u987e4. \u81ea\u52a8\u5316\u6784\u5efa&#xff1a;make \/ Makefile\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f4-1 \u80cc\u666f\u624b\u52a8\u7f16\u8bd1\u9047\u5230\u7684\u95ee\u9898mak\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/115377.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-11T18:17:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261011181714-6acbd2aaa47fd.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/115377.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/115377.html\",\"name\":\"Linux\u7cfb\u5217\uff0805\uff09\u2014\u2014\u57fa\u7840\u5f00\u53d1\u5de5\u5177\uff08\u4e0b\uff09makefile\u3001git\u3001gdb - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-11T18:17:20+00:00\",\"dateModified\":\"2026-10-11T18:17:20+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/115377.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/115377.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/115377.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux\u7cfb\u5217\uff0805\uff09\u2014\u2014\u57fa\u7840\u5f00\u53d1\u5de5\u5177\uff08\u4e0b\uff09makefile\u3001git\u3001gdb\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linux\u7cfb\u5217\uff0805\uff09\u2014\u2014\u57fa\u7840\u5f00\u53d1\u5de5\u5177\uff08\u4e0b\uff09makefile\u3001git\u3001gdb - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/115377.html","og_locale":"zh_CN","og_type":"article","og_title":"Linux\u7cfb\u5217\uff0805\uff09\u2014\u2014\u57fa\u7840\u5f00\u53d1\u5de5\u5177\uff08\u4e0b\uff09makefile\u3001git\u3001gdb - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u2b50\ufe0f\u535a\u4e3b&#xff1a; \u6b64\u751f\u51b3int-CSDN\u535a\u5ba2 \u901f\u80dc\u6d3e\u5c31\u662f\u6700\u5927\u7684\u6295\u964d\u6d3e&#xff01;&#xff01;&#xff01; &#x1f525;\u70ed\u95e8\u4e13\u680f&#x1f525; \u6df1\u5165\u7406\u89e3 C \u7cfb\u5217 &#xff5c; \u7b97\u6cd5\u7cfb\u5217 \u5feb\u901f\u590d\u4e60\u7cfb\u5217 &#xff5c; Linux\u7cfb\u5217 Gitee\u5730\u5740&#xff1a;\u8d22\u54e5 | GitHub\u5730\u5740&#xff1a;\u8d22\u54e5 \u6587\u7ae0\u76ee\u5f55\u4e0a\u671f\u56de\u987e4. \u81ea\u52a8\u5316\u6784\u5efa&#xff1a;make \/ Makefile\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f\u2b50\ufe0f4-1 \u80cc\u666f\u624b\u52a8\u7f16\u8bd1\u9047\u5230\u7684\u95ee\u9898mak","og_url":"https:\/\/www.wsisp.com\/helps\/115377.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-11T18:17:20+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261011181714-6acbd2aaa47fd.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"12 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/115377.html","url":"https:\/\/www.wsisp.com\/helps\/115377.html","name":"Linux\u7cfb\u5217\uff0805\uff09\u2014\u2014\u57fa\u7840\u5f00\u53d1\u5de5\u5177\uff08\u4e0b\uff09makefile\u3001git\u3001gdb - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-11T18:17:20+00:00","dateModified":"2026-10-11T18:17:20+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/115377.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/115377.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/115377.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Linux\u7cfb\u5217\uff0805\uff09\u2014\u2014\u57fa\u7840\u5f00\u53d1\u5de5\u5177\uff08\u4e0b\uff09makefile\u3001git\u3001gdb"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/115377","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=115377"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/115377\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/115371"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=115377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=115377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=115377"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=115377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}