{"id":42618,"date":"2025-06-10T01:04:27","date_gmt":"2025-06-09T17:04:27","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/42618.html"},"modified":"2025-06-10T01:04:27","modified_gmt":"2025-06-09T17:04:27","slug":"%e3%80%90linux%e3%80%91linux%e4%b8%8b%e7%ac%ac%e4%b8%80%e4%b8%aa%e7%a8%8b%e5%ba%8f%ef%bc%9a%e8%bf%9b%e5%ba%a6%e6%9d%a1","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/42618.html","title":{"rendered":"\u3010Linux\u3011LInux\u4e0b\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\uff1a\u8fdb\u5ea6\u6761"},"content":{"rendered":"<h2>\u524d\u8a00&#xff1a;<\/h2>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u5728\u524d\u9762\u7684\u6587\u7ae0\u4e2d\u6211\u4eec\u5b66\u4e60\u4e86LInux\u7684\u57fa\u7840\u6307\u4ee4<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u3010Linux\u3011\u521d\u89c1&#xff0c;\u57fa\u7840\u6307\u4ee4-CSDN\u535a\u5ba2\u3010Linux\u3011\u521d\u89c1&#xff0c;\u57fa\u7840\u6307\u4ee4&#xff08;\u7eed&#xff09;-CSDN\u535a\u5ba2<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u5b66\u4e60\u4e86vim\u7f16\u8f91\u5668\u3010Linux\u3011vim\u7f16\u8f91\u5668_linux vim insert-CSDN\u535a\u5ba2<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u5b66\u4e60\u4e86gcc\/g&#043;&#043;\u3010Linux\u3011\u7f16\u8bd1\u5668gcc\/g&#043;&#043;\u53ca\u5176\u5e93\u7684\u8be6\u7ec6\u4ecb\u7ecd-CSDN\u535a\u5ba2<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u4ee5\u53camake\/makefile\u3010Linux\u3011\u81ea\u52a8\u5316\u6784\u5efa-Make\/Makefile-CSDN\u535a\u5ba2<\/p>\n<\/p>\n<p>\u6709\u4e86\u4ee5\u4e0a\u77e5\u8bc6\u7684\u94fa\u57ab&#xff0c;\u6211\u4eec\u7ec8\u4e8e\u53ef\u4ee5\u5f00\u59cb\u5728Linux\u4e0a\u7f16\u5199\u8fd0\u884c\u6211\u4eec\u7684\u4ee3\u7801&#xff0c;\u4e8e\u662f\u6211\u4eec\u6765\u5230\u4e86Linux\u4e0b\u7684\u7b2c\u4e00\u4e2a\u7a0b\u5e8f&#xff1a;\u8fdb\u5ea6\u6761<\/p>\n<h2>1.\u56de\u8f66\u6362\u884c\u7b26\u00a0<\/h2>\n<p>\u00a0 \u00a0 \u00a0 \u00a0\u5927\u591a\u6570\u4eba\u53ef\u80fd\u89c9\u5f97&#034;\u56de\u8f66\u6362\u884c&#034;\u8fd9\u4e00\u8bcd\u6307\u7684\u662f\u540c\u4e00\u4e2a\u4e1c\u897f\u3002\u4f46\u5176\u5b9e\u56de\u8f66\u662f\u56de\u8f66\u3001\u6362\u884c\u662f\u6362\u884c&#xff0c;\u8fd9\u4e24\u4e2a\u6709\u672c\u8d28\u533a\u522b\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u6211\u4eec\u65e5\u5e38\u4f7f\u7528\u7684\u56de\u8f66\u952e\u5408\u6210\u4e86&#034;\u56de\u8f66&#034;\u548c&#034;\u6362\u884c&#034;\u529f\u80fd&#xff0c;\u8fd9\u5c31\u5bfc\u81f4\u4e86\u5927\u5bb6\u89c9\u5f97\u8fd9\u662f\u4e00\u4e2a\u4e1c\u897f\u3002<\/p>\n<p><span style=\"background-color:null\">\u56de\u8f66\u7684\u7b26\u53f7\u4e3a&#xff1a;\\\\n<\/span> <span style=\"background-color:null\">\u56de\u8f66\u7684\u529f\u80fd\u662f\u5c06\u5149\u6807\u91cd\u7f6e\u5230\u6700\u5f00\u59cb\u4f4d\u7f6e<\/span><\/p>\n<p><span style=\"background-color:null\">\u6362\u884c\u7684\u7b26\u53f7\u4e3a&#xff1a;\\\\r\u00a0<\/span> <span style=\"background-color:null\">\u6362\u884c\u7684\u529f\u80fd\u662f\u5c06\u5149\u6807\u4e0b\u79fb\u4e00\u884c<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"732\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250609170422-6847141688dbc.png\" width=\"1434\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"665\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250609170422-68471416d564d.png\" width=\"1386\" \/><\/p>\n<h2>2.\u7f13\u51b2\u533a\u95ee\u9898<\/h2>\n<p>\u4ec0\u4e48\u662f\u7f13\u51b2\u533a&#xff1f;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7f13\u51b2\u533a\u662f\u7cfb\u7edf\u9884\u7559\u7684\u5185\u5b58\u533a\u57df&#xff0c;\u5176\u4f5c\u7528\u662f\u6682\u65f6\u5b58\u653e\u8f93\u5165\u6216\u8f93\u51fa\u7684\u6570\u636e\u3002\u5f15\u5165\u7f13\u51b2\u533a\u4e3b\u8981\u662f\u4e3a\u4e86\u5e73\u8861\u9ad8\u901f\u7684 CPU \u4e0e\u4f4e\u901f\u7684 I\/O \u8bbe\u5907\u4e4b\u95f4\u7684\u901f\u5ea6\u5dee\u5f02&#xff0c;\u8fdb\u800c\u63d0\u5347\u7cfb\u7edf\u7684\u6574\u4f53\u6027\u80fd\u3002<\/p>\n<p>\u5237\u65b0\u7f13\u51b2\u533a&#xff1f;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u901a\u5e38\u60c5\u51b5\u4e0b&#xff0c;\u6570\u636e\u4f1a\u5148\u88ab\u5b58\u50a8\u5728\u7f13\u51b2\u533a\u4e2d&#xff0c;<span style=\"background-color:#ffd900\">\u53ea\u6709\u5f53\u7f13\u51b2\u533a\u6ee1\u3001\u9047\u5230\u7279\u5b9a\u7684\u63a7\u5236\u5b57\u7b26&#xff0c;\u6216\u8005\u7a0b\u5e8f\u8fd0\u884c\u7ed3\u675f\u65f6&#xff0c;\u624d\u4f1a\u5c06\u6570\u636e\u771f\u6b63\u5199\u5165\u76ee\u6807\u8bbe\u5907<\/span>\u3002\u4e0d\u8fc7&#xff0c;\u5728\u67d0\u4e9b\u7279\u5b9a\u573a\u666f\u4e0b&#xff0c;\u53ef\u80fd\u9700\u8981\u624b\u52a8\u5237\u65b0\u7f13\u51b2\u533a&#xff0c;\u4ee5\u786e\u4fdd\u6570\u636e\u80fd\u53ca\u65f6\u8f93\u51fa\u3002<\/p>\n<p>\u4e3e\u4f8b&#xff1a;<\/p>\n<p>\/\/\u4ee3\u78011<br \/>\n#include&lt;stdio.h&gt;<br \/>\n#include&lt;unistd.h&gt;<br \/>\nint main()<br \/>\n{<\/p>\n<p>    printf(&#034;hello\\\\n&#034;);<br \/>\n    sleep(3);<br \/>\n}<\/p>\n<p>\/\/\u4ee3\u78012<br \/>\n#include&lt;stdio.h&gt;<br \/>\n#include&lt;unistd.h&gt;<br \/>\nint main()<br \/>\n{<br \/>\n    printf(&#034;hello&#034;);<br \/>\n    sleep(3);<br \/>\n} <\/p>\n<p>\u8fd0\u884c\u4ee3\u78011&#xff1a;\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u663e\u793a\u5c4f\u4e0a\u9a6c\u4e0a\u663e\u793a\u51fa&#034;hello&#034;&#xff0c;\u7136\u540e\u505c\u6ede3\u79d2\u7ed3\u675f\u7a0b\u5e8f<\/p>\n<p>\u8fd0\u884c\u4ee3\u78012&#xff1a;\u6211\u4eec\u770b\u5230\u662f\u6070\u6070\u76f8\u53cd&#xff0c;\u5148\u505c\u6ede3\u79d2\u540e\u6253\u5370\u51fa&#034;hello&#034;,\u7136\u540e\u7ed3\u675f\u7a0b\u5e8f<\/p>\n<p>\u8fd9\u4e2a\u5c31\u662f\u7f13\u51b2\u533a\u7684\u95ee\u9898&#xff1a;&#034;\\\\n&#034;\u53ef\u4ee5\u9a6c\u4e0a\u5237\u65b0\u7f13\u51b2\u533a&#xff0c;\u6240\u4ee5\u4ee3\u78011\u53ef\u4ee5\u9a6c\u4e0a\u663e\u793a\u3002\u800c\u6ca1\u6709&#034;\\\\n&#034;&#xff0c;\u5c31\u65e0\u6cd5\u9a6c\u4e0a\u5237\u65b0\u7f13\u51b2\u533a&#xff0c;\u5f53\u6574\u4e2a\u7a0b\u5e8f\u7ed3\u675f\u540e\u7cfb\u7edf\u81ea\u52a8\u5237\u65b0&#xff0c;\u663e\u793a&#034;hello&#034;<\/p>\n<p><span style=\"background-color:#ffd900\">\u90a3\u5982\u4f55\u4f7f\u5176\u9a6c\u4e0a\u5237\u65b0?<\/span><\/p>\n<p>fflush(stdout) <\/p>\n<h2>3.\u9884\u5907\u4ee3\u7801<\/h2>\n<p>\u5148\u521b\u5efa\u6587\u4ef6\u5939&#xff0c;\u5e76\u5728\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u76f8\u5e94\u7684.c .h\u6587\u4ef6<\/p>\n<p>hyc&#064;hcss-ecs-4ce7:~$ mkdir progress<br \/>\nhyc&#064;hcss-ecs-4ce7:~$ cd progress<br \/>\nhyc&#064;hcss-ecs-4ce7:~\/progress$ touch p.c p.h main.c<\/p>\n<p>\u7f16\u5199\u4ee3\u7801&#xff0c;\u4e0emakefile\u3002\u8fdb\u5ea6\u6761\u53ea\u4f1a\u5728\u4e00\u884c\u6253\u5370&#xff0c;\u6240\u4ee5\u6211\u4eec\u4e0d\u80fd\u4f7f\u7528 \\\\n&#xff0c;\u800c\u662f\u4f7f\u7528 \\\\r&#xff0c;\u5728\u540c\u4e00\u884c\u6253\u5370<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"568\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250609170423-6847141726a31.png\" width=\"1441\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"647\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250609170423-68471417604c1.png\" width=\"1368\" \/><\/p>\n<p>\u4f46\u662f\u5f53\u6211\u4eec\u8fd0\u884c\u4ee3\u7801\u65f6&#xff0c;\u53d1\u73b0\u5e76\u6ca1\u6709\u663e\u793a\u7ed3\u679c\u3002\u8fd9\u662f\u56e0\u4e3a\u5f53\u524d\u6570\u636e\u8fd8\u5728\u7f13\u51b2\u533a\u6ca1\u6709\u5237\u65b0\u51fa\u6765&#xff0c;<span style=\"background-color:#ffd900\">\u6211\u4eec\u4f7f\u7528ffulsh(stdout)\u4f7f\u5176\u9a6c\u4e0a\u5237\u65b0<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"497\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250609170423-68471417a0837.png\" width=\"1128\" \/><\/p>\n<p>\u8fd9\u65f6\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u7ed3\u679c&#xff1a;\u5728\u540c\u4e00\u4f4d\u7f6e\u4e0a\u663e\u793a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"154\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250609170423-68471417d5788.png\" width=\"1030\" \/><\/p>\n<h2>4.\u8fdb\u5ea6\u6761\u4ee3\u7801<\/h2>\n<h4>4.1\u9996\u5148\u5148\u770b\u770b\u6211\u4eec\u60f3\u5b9e\u73b0\u4e00\u4e2a\u4ec0\u4e48\u6837\u5b50\u7684\u8fdb\u5ea6\u6761<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"480\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250609170423-68471417f121b.png\" width=\"1251\" \/><\/p>\n<h4>4.2\u4ee3\u7801\u5b9e\u73b0\u00a0<\/h4>\n<p>\u6211\u4eec\u4e00\u6b65\u4e00\u6b65\u6765&#xff0c;\u5148\u5b9e\u73b0\u5de6\u4fa7\u90e8\u5206<\/p>\n<p>1.\u8003\u8651\u4f7f\u7528\u5b57\u7b26\u6570\u7ec4\u6765\u8868\u793a\u9012\u589e\u7684\u8fdb\u5ea6\u6761\u3002\u5148\u5c06\u5b57\u7b26\u6570\u7ec4\u521d\u59cb\u5316\u4e3a \u2018\\\\0\u2019&#xff0c;\u901a\u8fc7%s\u6253\u5370\u65f6\u9047\u5230 \u2018\\\\0\u2019\u5c31\u4f1a\u505c\u6b62\u3002<\/p>\n<p>2.\u901a\u8fc7\u8ba1\u6570\u5668\u8ba1\u6570&#xff0c;\u6765\u8ba1\u7b97\u8f93\u51fa\u591a\u5c11\u7b26\u53f7<\/p>\n<p>3.\u901a\u8fc7fflush(stdout)\u7acb\u9a6c\u5237\u65b0\u7f13\u51b2\u533a&#xff0c;\u8ba9\u6211\u4eec\u770b\u5230\u7ed3\u679c<\/p>\n<p>4.\u901a\u8fc7sleep\u8ba9\u6211\u4eec\u770b\u5230\u5176\u8fc7\u7a0b<\/p>\n<p>5.\u6700\u540e\u4e3a\u4e86\u907f\u514d\u547d\u4ee4\u884c\u8986\u76d6\u6211\u4eec\u8f93\u51fa\u7684\u5185\u5bb9&#xff0c;\u8fdb\u884c\u6362\u884c\u64cd\u4f5c<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"707\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250609170424-6847141831218.png\" width=\"1482\" \/><\/p>\n<p>\u6700\u540e\u6dfb\u52a0\u4e00\u4e0b\u5de6\u53f3\u4e2d\u62ec\u53f7&#xff0c;\u4fee\u6539\u4e00\u4e0b\u7ec6\u8282\u95ee\u9898&#xff1a;<\/p>\n<p>\u6253\u5370\u8fdb\u5ea6\u6761\u4f7f\u7528%-100s\u5360\u4f4d\u7b26<\/p>\n<p>sleep\u6709\u70b9\u592a\u6162\u4e86&#xff0c;\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528usleep<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"696\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250609170424-68471418830e5.png\" width=\"1512\" \/><\/p>\n<p>#include&#034;p.h&#034;<br \/>\n#include&lt;unistd.h&gt;<br \/>\n#include&lt;string.h&gt;<\/p>\n<p>void progress_v1()<br \/>\n{<br \/>\n    char arr[101];<br \/>\n    memset(arr,&#039;\\\\0&#039;,sizeof(arr));<br \/>\n    int num&#061;0;<br \/>\n    for(int i&#061;0;i&lt;&#061;101;i&#043;&#043;)<br \/>\n    {<br \/>\n        arr[num]&#061;&#039;X&#039;;<br \/>\n        printf(&#034;[%-100s]\\\\r&#034;,arr);<br \/>\n        fflush(stdout);<br \/>\n        usleep(10000);<br \/>\n        num&#043;&#043;;<br \/>\n    }<br \/>\n    printf(&#034;\\\\n&#034;);<br \/>\n}   <\/p>\n<p>\u6548\u679c&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"393\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250609170424-68471418cfc57.png\" width=\"1674\" \/><\/p>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u5c31\u53ef\u4ee5\u6765\u8003\u8651\u4e00\u4e0b\u767e\u5206\u6bd4\u548c\u65cb\u8f6c\u5149\u6807\u4e86<\/p>\n<p>1.\u767e\u5206\u6bd4\u76f4\u63a5\u53bb\u8ba1\u7b97\u5c31\u597d\u4e86&#xff0c;\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\u3002<\/p>\n<p>2.\u65cb\u8f6c\u5149\u6807&#xff1a;\u6211\u4eec\u4e0d\u8981\u53bb\u60f3\u590d\u6742\u4e86&#xff0c;\u52a8\u6001\u7684\u672c\u8d28\u5176\u5b9e\u5c31\u662f\u4e00\u5e27\u4e00\u5e27\u7684\u9759\u6001\u56fe\u50cf&#xff0c;\u6211\u4eec\u53ea\u9700\u8981\u5199\u4e00\u4e2a\u5b57\u7b26\u6570\u7ec4x&#xff0c;\u7136\u540e\u4e0d\u65ad\u7684\u6253\u5370\u5b57\u7b26&#xff0c;\u5c31\u53ef\u4ee5\u5b9e\u73b0\u65cb\u8f6c\u5149\u6807\u4e86\u3002\u00a0<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"737\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250609170425-68471419249f8.png\" width=\"1569\" \/><\/p>\n<p>#include&lt;stdio.h&gt;<br \/>\n#include&lt;unistd.h&gt;<br \/>\n#include&lt;string.h&gt;<\/p>\n<p>void progress_v1()<br \/>\n{<br \/>\n    char arr[101];<br \/>\n    char x[]&#061;{&#039;\/&#039;,&#039;-&#039;,&#039;\\\\\\\\&#039;,&#039;\\\\0&#039;};<br \/>\n    memset(arr,&#039;\\\\0&#039;,sizeof(arr));<br \/>\n    int num&#061;0;<br \/>\n    for(int i&#061;0;i&lt;&#061;101;i&#043;&#043;)<br \/>\n    {<br \/>\n        arr[num]&#061;&#039;X&#039;;<br \/>\n        printf(&#034;[%-100s][%.2f][%c]\\\\r&#034;,arr,num*1.0\/sizeof(arr)*100,x[num%3]);<br \/>\n        fflush(stdout);<br \/>\n        usleep(10000);<br \/>\n        num&#043;&#043;;<br \/>\n    }<br \/>\n    printf(&#034;\\\\n&#034;);<br \/>\n}   <\/p>\n<p>\u6548\u679c\u6f14\u793a&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"597\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250609170425-68471419ac4c7.png\" width=\"1920\" \/><\/p>\n<h2><\/h2>\n<h2>5.\u6a21\u62df\u771f\u5b9e\u73af\u5883<\/h2>\n<p>\u4e00\u4e2a\u771f\u6b63\u7684\u8fdb\u5ea6\u6761\u4e0d\u53ef\u80fd\u5c31\u6211\u4eec\u4e0a\u9762\u5199\u7684\u4ee3\u7801\u4e00\u6837\u81ea\u987e\u81ea\u7684\u6253\u5370\u3002\u5e94\u8be5\u662f\u6839\u636e\u5b9e\u9645\u60c5\u51b5&#xff0c;\u4e00\u8fb9\u4e0b\u8f7d&#xff08;\u6216\u5176\u4ed6\u64cd\u4f5c&#xff09;&#xff0c;\u4e00\u8fb9\u6253\u5370\u8fdb\u5ea6\u6761\u3002<\/p>\n<p><span style=\"background-color:#ffd900\">\u4e8e\u662f\u6211\u4eec\u5b9e\u73b0\u4e00\u4e2adownload\u51fd\u6570\u6a21\u62df\u5b9e\u65f6\u4e0b\u8f7d\u73af\u5883<\/span>&#xff1a;\u00a0<\/p>\n<p>total&#xff1a;\u8868\u793a\u4e00\u5171\u60f3\u8981\u4e0b\u8f7d\u7684\u91cf<\/p>\n<p>speed&#xff1a;\u8868\u793a\u5355\u6b21\u4e0b\u8f7d\u7684\u901f\u5ea6<\/p>\n<p>\u6bcf\u4e0b\u8f7d\u4e00\u6b21\u5c31\u66f4\u65b0\u4e00\u6b21\u8fdb\u5ea6\u6761<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"834\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250609170426-6847141a2b62f.png\" width=\"1260\" \/><\/p>\n<p><span style=\"background-color:#ffd900\">\u901a\u8fc7\u5b9e\u65f6\u7684\u4e0b\u8f7d\u91cf\u6765\u8ba1\u7b97\u8fdb\u5ea6\u6761\u4e2d\u9700\u8981\u6253\u5370\u7684\u4e2a\u6570&#xff0c;\u4ee5\u53ca\u767e\u5206\u6bd4\u3002\u00a0<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"661\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250609170426-6847141a8120f.png\" width=\"1233\" \/><\/p>\n<h2><\/h2>\n<h2>\u4ee3\u7801\u6c47\u603b&#xff1a;\u00a0<\/h2>\n<p>\/\/p.h<\/p>\n<p>#include&lt;stdio.h&gt;<br \/>\nvoid progress_v1();<br \/>\nvoid progress_v2(double cur,double total);        <\/p>\n<p>\/\/p.c<\/p>\n<p>#include&#034;p.h&#034;<br \/>\n#include&lt;unistd.h&gt;<br \/>\n#include&lt;string.h&gt;<\/p>\n<p>void progress_v1()<br \/>\n{<br \/>\n    char arr[101];<br \/>\n    char x[]&#061;{&#039;\/&#039;,&#039;-&#039;,&#039;\\\\\\\\&#039;,&#039;\\\\0&#039;};<br \/>\n    memset(arr,&#039;\\\\0&#039;,sizeof(arr));<br \/>\n    int num&#061;0;<br \/>\n    for(int i&#061;0;i&lt;&#061;101;i&#043;&#043;)<br \/>\n    {<br \/>\n        arr[num]&#061;&#039;X&#039;;<br \/>\n        printf(&#034;[%-100s][%.2f][%c]\\\\r&#034;,arr,num*1.0\/sizeof(arr)*100,x[num%3]);<br \/>\n        fflush(stdout);<br \/>\n        usleep(10000);<br \/>\n        num&#043;&#043;;<br \/>\n    }<br \/>\n    printf(&#034;\\\\n&#034;);<br \/>\n}<\/p>\n<p>void progress_v2(double cur,double total)<br \/>\n{<br \/>\n    char arr[101];<br \/>\n    char x[]&#061;{&#039;\/&#039;,&#039;-&#039;,&#039;\\\\\\\\&#039;,&#039;\\\\0&#039;};<br \/>\n    memset(arr,&#039;\\\\0&#039;,sizeof(arr));<\/p>\n<p>    \/\/get the number<br \/>\n    int num&#061;(int)(cur*100\/total);<br \/>\n    for(int i&#061;0;i&lt;num;i&#043;&#043;)<br \/>\n    {<br \/>\n        arr[i]&#061;&#039;X&#039;;<br \/>\n    }   <\/p>\n<p>    printf(&#034;[%-100s][%.2f][%c]\\\\r&#034;,arr,cur*100\/total,x[num%3]);<br \/>\n    fflush(stdout);<br \/>\n}<\/p>\n<p>\/\/main.c<\/p>\n<p>#include &lt;stdio.h&gt;<br \/>\nint main()<br \/>\n{<br \/>\n    printf(&#034;Hello world\\\\n&#034;);<br \/>\n    return 0;<br \/>\n}                                                                                                                                         <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.6k\u6b21\uff0c\u70b9\u8d5e46\u6b21\uff0c\u6536\u85cf64\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u5728Linux\u73af\u5883\u4e0b\u7f16\u5199\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\u2014\u2014\u8fdb\u5ea6\u6761\u7684\u5b9e\u73b0\u8fc7\u7a0b\u3002\u9996\u5148\u8bb2\u89e3\u4e86\u56de\u8f66\u6362\u884c\u7b26\u7684\u533a\u522b\u53ca\u7f13\u51b2\u533a\u539f\u7406\uff0c\u901a\u8fc7\u793a\u4f8b\u4ee3\u7801\u5c55\u793a\u4e86\u7f13\u51b2\u533a\u5237\u65b0\u95ee\u9898\u3002\u968f\u540e\u8be6\u7ec6\u8bb2\u89e3\u4e86\u8fdb\u5ea6\u6761\u7684\u5b9e\u73b0\u6b65\u9aa4\uff1a\u4f7f\u7528\u5b57\u7b26\u6570\u7ec4\u8868\u793a\u8fdb\u5ea6\uff0c\u901a\u8fc7fflush\u5237\u65b0\u7f13\u51b2\u533a\uff0c\u6dfb\u52a0\u767e\u5206\u6bd4\u548c\u65cb\u8f6c\u5149\u6807\u6548\u679c\u3002\u6700\u540e\u6a21\u62df\u771f\u5b9e\u4e0b\u8f7d\u73af\u5883\uff0c\u5b9e\u73b0\u52a8\u6001\u66f4\u65b0\u7684\u8fdb\u5ea6\u6761\u529f\u80fd\u3002\u6587\u7ae0\u8fd8\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684\u4ee3\u7801\u5b9e\u73b0\uff0c\u5305\u62ecmakefile\u6587\u4ef6\uff0c\u5e2e\u52a9\u8bfb\u8005\u5728Linux\u7cfb\u7edf\u4e0a\u5feb\u901f\u6784\u5efa\u548c\u8fd0\u884c\u8fdb\u5ea6\u6761\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"author":2,"featured_media":42604,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1054,58,43,305,44,3974],"topic":[],"class_list":["post-42618","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-c-c","tag-linux","tag-43","tag-305","tag-44","tag-3974"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010Linux\u3011LInux\u4e0b\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\uff1a\u8fdb\u5ea6\u6761 - \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\/42618.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010Linux\u3011LInux\u4e0b\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\uff1a\u8fdb\u5ea6\u6761 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.6k\u6b21\uff0c\u70b9\u8d5e46\u6b21\uff0c\u6536\u85cf64\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u5728Linux\u73af\u5883\u4e0b\u7f16\u5199\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\u2014\u2014\u8fdb\u5ea6\u6761\u7684\u5b9e\u73b0\u8fc7\u7a0b\u3002\u9996\u5148\u8bb2\u89e3\u4e86\u56de\u8f66\u6362\u884c\u7b26\u7684\u533a\u522b\u53ca\u7f13\u51b2\u533a\u539f\u7406\uff0c\u901a\u8fc7\u793a\u4f8b\u4ee3\u7801\u5c55\u793a\u4e86\u7f13\u51b2\u533a\u5237\u65b0\u95ee\u9898\u3002\u968f\u540e\u8be6\u7ec6\u8bb2\u89e3\u4e86\u8fdb\u5ea6\u6761\u7684\u5b9e\u73b0\u6b65\u9aa4\uff1a\u4f7f\u7528\u5b57\u7b26\u6570\u7ec4\u8868\u793a\u8fdb\u5ea6\uff0c\u901a\u8fc7fflush\u5237\u65b0\u7f13\u51b2\u533a\uff0c\u6dfb\u52a0\u767e\u5206\u6bd4\u548c\u65cb\u8f6c\u5149\u6807\u6548\u679c\u3002\u6700\u540e\u6a21\u62df\u771f\u5b9e\u4e0b\u8f7d\u73af\u5883\uff0c\u5b9e\u73b0\u52a8\u6001\u66f4\u65b0\u7684\u8fdb\u5ea6\u6761\u529f\u80fd\u3002\u6587\u7ae0\u8fd8\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684\u4ee3\u7801\u5b9e\u73b0\uff0c\u5305\u62ecmakefile\u6587\u4ef6\uff0c\u5e2e\u52a9\u8bfb\u8005\u5728Linux\u7cfb\u7edf\u4e0a\u5feb\u901f\u6784\u5efa\u548c\u8fd0\u884c\u8fdb\u5ea6\u6761\u7a0b\u5e8f\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/42618.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-09T17:04:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250609170422-6847141688dbc.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=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/42618.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/42618.html\",\"name\":\"\u3010Linux\u3011LInux\u4e0b\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\uff1a\u8fdb\u5ea6\u6761 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-06-09T17:04:27+00:00\",\"dateModified\":\"2025-06-09T17:04:27+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/42618.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/42618.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/42618.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010Linux\u3011LInux\u4e0b\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\uff1a\u8fdb\u5ea6\u6761\"}]},{\"@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":"\u3010Linux\u3011LInux\u4e0b\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\uff1a\u8fdb\u5ea6\u6761 - \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\/42618.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010Linux\u3011LInux\u4e0b\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\uff1a\u8fdb\u5ea6\u6761 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.6k\u6b21\uff0c\u70b9\u8d5e46\u6b21\uff0c\u6536\u85cf64\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u5728Linux\u73af\u5883\u4e0b\u7f16\u5199\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\u2014\u2014\u8fdb\u5ea6\u6761\u7684\u5b9e\u73b0\u8fc7\u7a0b\u3002\u9996\u5148\u8bb2\u89e3\u4e86\u56de\u8f66\u6362\u884c\u7b26\u7684\u533a\u522b\u53ca\u7f13\u51b2\u533a\u539f\u7406\uff0c\u901a\u8fc7\u793a\u4f8b\u4ee3\u7801\u5c55\u793a\u4e86\u7f13\u51b2\u533a\u5237\u65b0\u95ee\u9898\u3002\u968f\u540e\u8be6\u7ec6\u8bb2\u89e3\u4e86\u8fdb\u5ea6\u6761\u7684\u5b9e\u73b0\u6b65\u9aa4\uff1a\u4f7f\u7528\u5b57\u7b26\u6570\u7ec4\u8868\u793a\u8fdb\u5ea6\uff0c\u901a\u8fc7fflush\u5237\u65b0\u7f13\u51b2\u533a\uff0c\u6dfb\u52a0\u767e\u5206\u6bd4\u548c\u65cb\u8f6c\u5149\u6807\u6548\u679c\u3002\u6700\u540e\u6a21\u62df\u771f\u5b9e\u4e0b\u8f7d\u73af\u5883\uff0c\u5b9e\u73b0\u52a8\u6001\u66f4\u65b0\u7684\u8fdb\u5ea6\u6761\u529f\u80fd\u3002\u6587\u7ae0\u8fd8\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684\u4ee3\u7801\u5b9e\u73b0\uff0c\u5305\u62ecmakefile\u6587\u4ef6\uff0c\u5e2e\u52a9\u8bfb\u8005\u5728Linux\u7cfb\u7edf\u4e0a\u5feb\u901f\u6784\u5efa\u548c\u8fd0\u884c\u8fdb\u5ea6\u6761\u7a0b\u5e8f\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/42618.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-06-09T17:04:27+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250609170422-6847141688dbc.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/42618.html","url":"https:\/\/www.wsisp.com\/helps\/42618.html","name":"\u3010Linux\u3011LInux\u4e0b\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\uff1a\u8fdb\u5ea6\u6761 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-06-09T17:04:27+00:00","dateModified":"2025-06-09T17:04:27+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/42618.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/42618.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/42618.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010Linux\u3011LInux\u4e0b\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\uff1a\u8fdb\u5ea6\u6761"}]},{"@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\/42618","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=42618"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/42618\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/42604"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=42618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=42618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=42618"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=42618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}