{"id":64595,"date":"2026-01-23T19:56:38","date_gmt":"2026-01-23T11:56:38","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/64595.html"},"modified":"2026-01-23T19:56:38","modified_gmt":"2026-01-23T11:56:38","slug":"c%e8%af%ad%e8%a8%80%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/64595.html","title":{"rendered":"C\u8bed\u8a00\u5b57\u7b26\u4e32\u64cd\u4f5c"},"content":{"rendered":"<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"-toc\" style=\"margin-left:0px\">\n<p id=\"%E4%B8%80%E7%BB%B4%E5%AD%97%E7%AC%A6%E6%95%B0%E7%BB%84-toc\" style=\"margin-left:0px\">\u4e00\u7ef4\u5b57\u7b26\u6570\u7ec4<\/p>\n<p id=\"%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%B8%B8%E7%94%A8%E7%9B%B8%E5%85%B3%E5%87%BD%E6%95%B0-toc\" style=\"margin-left:40px\">\u5b57\u7b26\u4e32\u5e38\u7528\u76f8\u5173\u51fd\u6570<\/p>\n<p id=\"%E8%8E%B7%E5%BE%97%E5%AD%97%E7%AC%A6%E4%B8%B2%E9%95%BF%E5%BA%A6%EF%BC%88strlen%EF%BC%89-toc\" style=\"margin-left:80px\">\u83b7\u5f97\u5b57\u7b26\u4e32\u957f\u5ea6&#xff08;strlen&#xff09;<\/p>\n<p id=\"%E7%B3%BB%E7%BB%9F%E8%B0%83%E7%94%A8%E5%87%BD%E6%95%B0-toc\" style=\"margin-left:120px\">\u7cfb\u7edf\u8c03\u7528\u51fd\u6570<\/p>\n<p id=\"%E4%B8%8D%E7%94%A8%E7%B3%BB%E7%BB%9F%E5%87%BD%E6%95%B0-toc\" style=\"margin-left:120px\">\u4e0d\u7528\u7cfb\u7edf\u51fd\u6570<\/p>\n<p id=\"%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%A4%8D%E5%88%B6%E6%93%8D%E4%BD%9C%EF%BC%88strcpy%EF%BC%89-toc\" style=\"margin-left:80px\">\u5b57\u7b26\u4e32\u590d\u5236\u64cd\u4f5c&#xff08;strcpy&#xff09;<\/p>\n<p id=\"%E7%B3%BB%E7%BB%9F%E8%B0%83%E7%94%A8%E5%87%BD%E6%95%B0-toc\" style=\"margin-left:120px\">\u7cfb\u7edf\u8c03\u7528\u51fd\u6570<\/p>\n<p id=\"%E4%B8%8D%E7%94%A8%E5%87%BD%E6%95%B0%E7%9A%84%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%A4%8D%E5%88%B6-toc\" style=\"margin-left:120px\">\u4e0d\u7528\u51fd\u6570\u7684\u5b57\u7b26\u4e32\u590d\u5236<\/p>\n<p id=\"%E6%96%B9%E6%B3%95%E4%B8%80-toc\" style=\"margin-left:160px\">\u65b9\u6cd5\u4e00<\/p>\n<p id=\"%E6%96%B9%E6%B3%95%E4%BA%8C-toc\" style=\"margin-left:160px\">\u65b9\u6cd5\u4e8c<\/p>\n<p id=\"%E6%96%B9%E6%B3%95%E4%B8%89-toc\" style=\"margin-left:160px\">\u65b9\u6cd5\u4e09<\/p>\n<p id=\"%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%9A%84%E6%8B%BC%E6%8E%A5%E5%87%BD%E6%95%B0%EF%BC%88strcat%EF%BC%89-toc\" style=\"margin-left:80px\">\u5b57\u7b26\u4e32\u7684\u62fc\u63a5\u51fd\u6570&#xff08;strcat&#xff09;<\/p>\n<p id=\"%E7%B3%BB%E7%BB%9F%E8%B0%83%E7%94%A8%E5%87%BD%E6%95%B0-toc\" style=\"margin-left:120px\">\u7cfb\u7edf\u8c03\u7528\u51fd\u6570<\/p>\n<p id=\"%E4%B8%8D%E7%94%A8%E5%87%BD%E6%95%B0-toc\" style=\"margin-left:120px\">\u4e0d\u7528\u51fd\u6570<\/p>\n<p id=\"%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%AF%94%E8%BE%83%EF%BC%88strcmp%EF%BC%89-toc\" style=\"margin-left:80px\">\u5b57\u7b26\u4e32\u6bd4\u8f83&#xff08;strcmp&#xff09;<\/p>\n<p id=\"%E7%B3%BB%E7%BB%9F%E5%87%BD%E6%95%B0-toc\" style=\"margin-left:120px\">\u7cfb\u7edf\u51fd\u6570<\/p>\n<p id=\"%E4%B8%8D%E7%94%A8%E5%87%BD%E6%95%B0-toc\" style=\"margin-left:120px\">\u4e0d\u7528\u51fd\u6570<\/p>\n<p id=\"%E4%BA%8C%E7%BB%B4%E5%AD%97%E7%AC%A6%E6%95%B0%E7%BB%84-toc\" style=\"margin-left:0px\">\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4<\/p>\n<p id=\"%E5%AE%9A%E4%B9%89%E7%9A%84%E8%AF%AD%E6%B3%95-toc\" style=\"margin-left:80px\">\u5b9a\u4e49\u7684\u8bed\u6cd5<\/p>\n<p id=\"%E5%88%9D%E5%A7%8B%E5%8C%96-toc\" style=\"margin-left:80px\">\u521d\u59cb\u5316<\/p>\n<p id=\"%E8%AE%BF%E9%97%AE%EF%BC%9A%E8%AF%BB-toc\" style=\"margin-left:80px\">\u8bbf\u95ee&#xff1a;\u8bfb<\/p>\n<p id=\"%E8%AE%BF%E9%97%AE%EF%BC%9A%E5%86%99-toc\" style=\"margin-left:80px\">\u8bbf\u95ee&#xff1a;\u5199<\/p>\n<p id=\"%EF%BC%81%E9%87%8D%E7%82%B9%EF%BC%81-toc\" style=\"margin-left:0px\">&#xff01;\u91cd\u70b9&#xff01;<\/p>\n<p id=\"%E7%AC%AC%E5%9B%9B%E7%AB%A0-toc\" style=\"margin-left:80px\">\u7b2c\u56db\u7ae0<\/p>\n<hr id=\"hr-toc\" \/>\n<h2 id=\"%E4%B8%80%E7%BB%B4%E5%AD%97%E7%AC%A6%E6%95%B0%E7%BB%84\" style=\"background-color:transparent\">\u4e00\u7ef4\u5b57\u7b26\u6570\u7ec4<\/h2>\n<h3 id=\"%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%B8%B8%E7%94%A8%E7%9B%B8%E5%85%B3%E5%87%BD%E6%95%B0\" style=\"background-color:transparent\">\u5b57\u7b26\u4e32\u5e38\u7528\u76f8\u5173\u51fd\u6570<\/h3>\n<p>char\u00a0 str[10]&#061;&#034;hello&#034;;<\/p>\n<p>printf(&#034;%s\\\\n&#034;,str);<\/p>\n<p>scanf(&#034;%s&#034;,str);\u00a0 \u00a0 \u00a0 <span style=\"color:#4da8ee\">\/\/\u8fd9\u91cc\u4e0d\u7528\u52a0\u53d6\u5730\u5740&amp;\u00a0 \u00a0 &#xff0c;\u8f93\u5165zhangsan\u8f93\u51fazhangsan&#xff0c;<\/span><span style=\"color:#956fe7\">\u4f46\u662f<\/span><span style=\"color:#4da8ee\">&#xff0c;\u8f93\u5165zhang san\u53ea\u80fd\u8f93\u51fazhang&#xff0c;\u56e0\u4e3ascanf&#xff08;&#xff09;\u628a\u7a7a\u683c\u3001tab\u3001\u56de\u8f66\u770b\u4e3a\u7ed3\u675f\u6807\u5fd7\u3002<\/span><\/p>\n<\/p>\n<p>gets();\u00a0 \u00a0\/\/gets\u5728\u63a5\u6536\u5b57\u7b26\u4e32\u7684\u65f6\u5019\u53ef\u4ee5\u63a5\u53d7 \u7a7a\u683c&#xff0c;\u9047\u5230\\\\n&#xff0c;\u8868\u793a\u8f93\u5165\u7ed3\u679c<\/p>\n<ul>\n<li>\n<h4 id=\"%E8%8E%B7%E5%BE%97%E5%AD%97%E7%AC%A6%E4%B8%B2%E9%95%BF%E5%BA%A6%EF%BC%88strlen%EF%BC%89\">\u83b7\u5f97\u5b57\u7b26\u4e32\u957f\u5ea6&#xff08;strlen&#xff09;<\/h4>\n<\/li>\n<\/ul>\n<p>&#xff08;string length&#xff09;\u6c42\u5f97\u6709\u6548\u5b57\u7b26\u4e32\u7684\u957f\u5ea6<\/p>\n<p>char str[50]&#061;&#034;hello&#034;;\u00a0 \u00a0\/\/\u5b57\u7b26\u4e32\u957f\u5ea6\u4e3a5&#xff0c;\u4ece\u7b2c\u4e00\u4e2a\u5b57\u7b26\u5f00\u59cb\u8ba1\u6570&#xff0c;\u5230\u5b57\u7b26\u4e32\u7684\\\\0&#xff08;\u7ed3\u675f\u6807\u5fd7&#xff09;\u4ee5\u524d\u7684\u957f\u5ea6\u4e3a\u5b57\u7b26\u4e32\u957f\u5ea6\u3002<\/p>\n<p><span style=\"color:#fe2c24\">\u6ce8\u610f\u533a\u522b<\/span>&#xff1a;sizeof&#xff08;str&#xff09;\u662f\u5185\u5b58\u5360\u591a\u5927&#xff0c;sizeof&#xff08;\u57fa\u7c7b\u578b&#xff09;*\u5143\u7d20\u4e2a\u6570\u00a0 \u00a0 &#xff1a;\u00a0 1*50 &#061; 50 byte<\/p>\n<\/p>\n<p><span style=\"color:#4da8ee\">\u6bd4\u5982\u8bf4<\/span>&#xff1a;\u201chello\u201d\u8fd9\u4e2a\u5b57\u7b26\u4e32\u5360\u7684<span style=\"color:#1c7331\">\u5185\u5b58\u5927\u5c0f<\/span>&#xff08;<span style=\"color:#1c7331\">sizeof<\/span>&#xff09;\u662f6&#xff0c;\u56e0\u4e3a\u540e\u9762\u8fd8\u6709\u4e00\u4e2a&#039;\\\\0&#039;&#xff0c;\u5b83\u7684\u6709\u6548\u5b57\u7b26\u4e32\u957f\u5ea6&#xff08;strlen&#xff09;\u662f5<\/p>\n<h5 id=\"%E7%B3%BB%E7%BB%9F%E8%B0%83%E7%94%A8%E5%87%BD%E6%95%B0\">\u7cfb\u7edf\u8c03\u7528\u51fd\u6570<\/h5>\n<p>strlen&#xff08;str&#xff09;<\/p>\n<h5 id=\"%E4%B8%8D%E7%94%A8%E7%B3%BB%E7%BB%9F%E5%87%BD%E6%95%B0\">\u4e0d\u7528\u7cfb\u7edf\u51fd\u6570<\/h5>\n<p>#include &lt;stdio.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\nint main()<br \/>\n{<br \/>\nchar str[50]&#061;&#034;hello&#034;;<br \/>\nprintf(&#034;input 49 char:&#034;);<br \/>\nscanf(&#034;%s&#034;,str);<br \/>\nint len &#061;0;<\/p>\n<p>int i&#061;0;<br \/>\nwhile(1)<br \/>\n{<br \/>\nif(&#039;\\\\0&#039; !&#061;str[i])<br \/>\n{<br \/>\nlen&#043;&#043;;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nbreak;<br \/>\n}<br \/>\ni&#043;&#043;;<br \/>\n}<\/p>\n<p>printf(&#034;sizeof() is %lu\\\\n&#034;,sizeof(str));  \/\/\u8fd9\u4e2a\u83b7\u5f97\u7684\u5927\u5c0f\u662f  \u6570\u7ec4\u5360\u7528\u7684\u5185\u5b58\u5927\u5c0f<br \/>\nprintf(&#034;strlen %d\\\\n&#034;,len);   \/\/\u8fd9\u4e2a\u83b7\u5f97\u7684\u662f\u5b57\u7b26\u4e32\u6709\u6548\u957f\u5ea6<\/p>\n<p>return 0;<br \/>\n} <\/p>\n<ul>\n<li>\n<h4 id=\"%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%A4%8D%E5%88%B6%E6%93%8D%E4%BD%9C%EF%BC%88strcpy%EF%BC%89\">\u5b57\u7b26\u4e32\u590d\u5236\u64cd\u4f5c&#xff08;strcpy&#xff09;<\/h4>\n<\/li>\n<\/ul>\n<p>\u6574\u4f53\u590d\u5236\u4e00\u4e2a\u5df2\u6709\u5185\u5bb9\u7684\u5b57\u7b26\u4e32&#xff08;\u6e90\u4e32&#xff09;&#xff0c;\u5230\u53e6\u5916\u4e00\u4e2a\u5b57\u7b26\u4e32&#xff08;\u76ee\u6807\u4e32&#xff09;\u3002\u6e90\u5b57\u7b26\u4e32\u7684\u5185\u5bb9\u548c\u76ee\u6807\u5b57\u7b26\u4e32\u7684\u5185\u5bb9\u76f8\u540c\u3002<\/p>\n<p>strcpy(mubiao_str,yuan_str);<\/p>\n<h5 id=\"%E7%B3%BB%E7%BB%9F%E8%B0%83%E7%94%A8%E5%87%BD%E6%95%B0\" style=\"background-color:transparent\">\u7cfb\u7edf\u8c03\u7528\u51fd\u6570<\/h5>\n<p> #include &lt;stdio.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\nint main()<br \/>\n{<br \/>\nchar yuan_str[100]&#061;&#034;hello&#034;;<br \/>\nchar mubiao_str[100]&#061;{0};<\/p>\n<p>strcpy(mubiao_str,yuan_str);<\/p>\n<p>printf(&#034;yuan_str:%s\\\\n&#034;,yuan_str);<br \/>\nprintf(&#034;mubiao_str:%s\\\\n&#034;,mubiao_str);<br \/>\nreturn 0;<br \/>\n}<\/p>\n<h5 id=\"%E4%B8%8D%E7%94%A8%E5%87%BD%E6%95%B0%E7%9A%84%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%A4%8D%E5%88%B6\">\u4e0d\u7528\u51fd\u6570\u7684\u5b57\u7b26\u4e32\u590d\u5236<\/h5>\n<p>\u4ece\u6e90\u5b57\u7b26\u4e32\u4e2d\u53d6\u4e00\u4e2a\u5b57\u7b26&#xff0c;\u5411\u76ee\u6807\u5b57\u7b26\u4e32\u5199\u5165\u4e00\u4e2a\u5b57\u7b26&#xff0c;\u4f9d\u6b21\u6267\u884c\u8fd9\u4e2a\u52a8\u4f5c\u3002\u5f53\u5b57\u7b26\u4e3a\\\\0\u65f6&#xff0c;\u7ed3\u675f\u5faa\u73af\u3002\u5728\u76ee\u6807\u5b57\u7b26\u4e32\u7684\u6700\u540e&#xff0c;\u52a0\u5165\u7ed3\u675f\u6807\u5fd7\u662f\\\\0\u3002<\/p>\n<h6 id=\"%E6%96%B9%E6%B3%95%E4%B8%80\" style=\"background-color:transparent\">\u65b9\u6cd5\u4e00<\/h6>\n<p>int len &#061;strlen(yuan_str);<\/p>\n<p> for(i&#061;0;i&lt;len;i&#043;&#043;)<br \/>\n{<br \/>\nmubiao_str[i]&#061;yuan_str[i];<br \/>\n}<br \/>\nmubiao_str[i]&#061;&#039;\\\\0&#039;;<\/p>\n<h6 id=\"%E6%96%B9%E6%B3%95%E4%BA%8C\">\u65b9\u6cd5\u4e8c<\/h6>\n<p> while(&#039;\\\\0&#039; !&#061;yuan_str[i])<br \/>\n{<br \/>\nmubiao_str[i] &#061;yuan_str[i];<br \/>\ni&#043;&#043;;<br \/>\n}<br \/>\nmubiao_str[i]&#061;&#039;\\\\0&#039;;<\/p>\n<h6 id=\"%E6%96%B9%E6%B3%95%E4%B8%89\">\u65b9\u6cd5\u4e09<\/h6>\n<p> while(mubiao_str[i] &#061; yuan_str[i])<br \/>\n{<br \/>\ni&#043;&#043;;<br \/>\n}<\/p>\n<ul>\n<li>\n<h4 id=\"%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%9A%84%E6%8B%BC%E6%8E%A5%E5%87%BD%E6%95%B0%EF%BC%88strcat%EF%BC%89\">\u5b57\u7b26\u4e32\u7684\u62fc\u63a5\u51fd\u6570&#xff08;strcat&#xff09;<\/h4>\n<\/li>\n<\/ul>\n<p>string concat<\/p>\n<p>strcat&#xff08;str2&#xff0c;str1&#xff09;\u628astr2\u62fc\u63a5\u5230str1<\/p>\n<p>\u5728\u5b57\u7b26\u4e32\u62fc\u63a5\u8fc7\u7a0b\u4e2d&#xff0c;str1\u9700\u8981\u6709\u8db3\u591f\u5927\u7684\u5185\u5b58\u7a7a\u95f4&#xff0c;\u5426\u5219\u7a0b\u5e8f\u4f1a\u51fa\u73b0\u6bb5\u9519\u8bef\u3001str1\u3001str3\u5185\u5b58\u7a7a\u95f4\u4f1a\u88ab\u610f\u5916\u4fee\u6539\u3002<\/p>\n<h5 id=\"%E7%B3%BB%E7%BB%9F%E8%B0%83%E7%94%A8%E5%87%BD%E6%95%B0\" style=\"background-color:transparent\">\u7cfb\u7edf\u8c03\u7528\u51fd\u6570<\/h5>\n<p>strcat&#xff08;\u88ab\u62fc\u63a5&#xff0c;\u62fc\u63a5&#xff09;&#xff1b;<\/p>\n<p> #include &lt;stdio.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\nint main()<br \/>\n{<br \/>\nchar str1[100]&#061;&#034;hello&#034;;<br \/>\nchar str2[10]&#061;&#034;world&#034;;<\/p>\n<p>strcat(str1,str2);<br \/>\nprintf(&#034;%s\\\\n&#034;,str1);<br \/>\nreturn 0;<br \/>\n}<\/p>\n<h5 id=\"%E4%B8%8D%E7%94%A8%E5%87%BD%E6%95%B0\" style=\"background-color:transparent\">\u4e0d\u7528\u51fd\u6570<\/h5>\n<ul>\n<li>\u5148\u8981\u627e\u5230str1\u5b57\u7b26\u4e32\u2018\\\\0\u2019\u7684\u4f4d\u7f6e&#xff0c;\u7528i\u6807\u8bb0<\/li>\n<li>\u4ecestr2\u4e2d\u4f9d\u6b21\u53d6\u51fa\u6bcf\u4e2a\u5b57\u7b26&#xff0c;\u5b58\u5165str[i]\u7684\u4f4d\u7f6e\u3002str[i&#043;&#043;] &#061; str[j&#043;&#043;]<\/li>\n<\/ul>\n<p> while(&#039;\\\\0&#039;!&#061;str1[i])<br \/>\n{<br \/>\ni&#043;&#043;;<br \/>\n}<br \/>\nwhile(str1[i]&#061;str2[j])<br \/>\n{<br \/>\ni&#043;&#043;;<br \/>\nj&#043;&#043;;<br \/>\n}<\/p>\n<h4 id=\"%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%AF%94%E8%BE%83%EF%BC%88strcmp%EF%BC%89\">\u5b57\u7b26\u4e32\u6bd4\u8f83&#xff08;strcmp&#xff09;<\/h4>\n<p>\u6bd4\u8f83\u4e24\u4e2a\u5b57\u7b26\u4e32\u7684\u5185\u5bb9&#xff08;string compare&#xff09;<\/p>\n<p>int strcmp(const char *s1,const char *s2);<\/p>\n<p>\u53c2\u6570<\/p>\n<ul>\n<li>s1&#xff0c;\u9700\u8981\u88ab\u6bd4\u8f83\u7684\u5b57\u7b26\u4e321&#xff1b;<\/li>\n<li>s2&#xff0c;\u9700\u8981\u88ab\u6bd4\u8f83\u7684\u5b57\u7b26\u4e322.<\/li>\n<\/ul>\n<p>\u8fd4\u56de\u503c<\/p>\n<ul>\n<li>&#061;&#061;0\u00a0 s1\u4e0es2 \u5185\u5bb9\u76f8\u540c<\/li>\n<li>&gt;0\u00a0 \u00a0\u5185\u5bb9\u4e0d\u4e00\u6837&#xff0c;\u4e0d\u4e00\u6837\u5904\u5bf9\u5e94\u7684\u5b57\u7b26s1[i] &#8211; s2[i] &gt;0<\/li>\n<li>&lt;0\u00a0 \u00a0\u00a0\u5185\u5bb9\u4e0d\u4e00\u6837&#xff0c;\u4e0d\u4e00\u6837\u5904\u5bf9\u5e94\u7684\u5b57\u7b26s1[i] &#8211; s2[i] &lt;0<\/li>\n<\/ul>\n<h5 id=\"%E7%B3%BB%E7%BB%9F%E5%87%BD%E6%95%B0\">\u7cfb\u7edf\u51fd\u6570<\/h5>\n<p>\u6838\u5fc3\u4ee3\u7801<\/p>\n<p> if(0&#061;&#061;strcmp(str1,str2)) <\/p>\n<p>\u5b8c\u6574\u4ee3\u7801<\/p>\n<p> #include &lt;stdio.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\nint main()<br \/>\n{<br \/>\nchar str1[10]&#061;&#034;hallo&#034;;<br \/>\nchar str2[10]&#061;&#034;hello&#034;;<br \/>\n\/*   \u9519\u8bef\u7684\u65b9\u6cd5<br \/>\nif(str1&#061;&#061;str2)<br \/>\n*\/<br \/>\n\/\/if(0&#061;&#061;strcmp(str1,str2))<br \/>\nint ret&#061;strcmp(str1,str2);<br \/>\nif(0&#061;&#061;ret)<br \/>\n{<br \/>\nprintf(&#034;same\\\\n&#034;);<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nprintf(&#034;not same\\\\n&#034;);<br \/>\n}<br \/>\nreturn 0;<br \/>\n}<\/p>\n<h5 id=\"%E4%B8%8D%E7%94%A8%E5%87%BD%E6%95%B0\">\u4e0d\u7528\u51fd\u6570<\/h5>\n<p>\u6838\u5fc3\u4ee3\u7801<\/p>\n<ul>\n<li>\u4f7f\u75281\u4e2a\u4e0b\u6807&#xff0c;\u5982\u679cstr1[i]\u548cstr2[i]\u76f8\u540c\u5c31\u7ee7\u7eed\u6bd4\u8f83\u4e0b\u4e00\u4e2a&#xff1b;<\/li>\n<li>\u5982\u679c\u4e0d\u540c&#xff0c;str1[i]-str2[i]\u5c31\u662f\u6bd4\u8f83\u7684\u7ed3\u679c\u3002<\/li>\n<\/ul>\n<p> while(str1[i]&#061;&#061;str2[i] &amp;&amp; str1[i]!&#061;&#039;\\\\0&#039;)<br \/>\n{<br \/>\ni&#043;&#043;;<br \/>\n}<br \/>\nret&#061;str1[i]-str2[i];<\/p>\n<p>\u5b8c\u6574\u4ee3\u7801<\/p>\n<p> #include &lt;stdio.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\nint main()<br \/>\n{<br \/>\nchar str1[10]&#061;&#034;hallo&#034;;<br \/>\nchar str2[10]&#061;&#034;hello&#034;;<\/p>\n<p>int i&#061;0;<br \/>\nint ret&#061;0;<br \/>\nwhile(str1[i]&#061;&#061;str2[i] &amp;&amp; str1[i]!&#061;&#039;\\\\0&#039;)<br \/>\n{<br \/>\ni&#043;&#043;;<br \/>\n}<br \/>\nret&#061;str1[i]-str2[i];<br \/>\nif(0&#061;&#061;ret)<br \/>\n{<br \/>\nprintf(&#034;same\\\\n&#034;);<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nprintf(&#034;not same\\\\n&#034;);<br \/>\n}<br \/>\nprintf(&#034;ret %d\\\\n&#034;,ret);<br \/>\nreturn 0;<br \/>\n}<\/p>\n<h2 id=\"%E4%BA%8C%E7%BB%B4%E5%AD%97%E7%AC%A6%E6%95%B0%E7%BB%84\">\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4<\/h2>\n<p>\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4\u662f\u7531\u591a\u4e2a\u4e00\u7ef4\u5b57\u7b26\u6570\u7ec4\u7ec4\u6210&#xff1b;\u53ef\u4ee5\u5b58\u50a8\u591a\u4e2a\u5b57\u7b26\u4e32\u7684\u6570\u7ec4\u3002<\/p>\n<h4 id=\"%E5%AE%9A%E4%B9%89%E7%9A%84%E8%AF%AD%E6%B3%95\">\u5b9a\u4e49\u7684\u8bed\u6cd5<\/h4>\n<p>char a[3][50];<\/p>\n<p>char \u6570\u7ec4\u7684\u540d\u5b57 \u3010\u884c\u6570\u3011 \u3010\u5217\u6570\u3011\u00a0 \u884c\u3001\u5217\u5fc5\u987b\u4e3a\u6574\u578b\u5e38\u91cf<\/p>\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"677\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260123115637-697361f50eefc.png\" width=\"1533\" \/><\/p>\n<h4 id=\"%E5%88%9D%E5%A7%8B%E5%8C%96\">\u521d\u59cb\u5316<\/h4>\n<p> \/\/\u521d\u59cb\u5316<br \/>\nchar strs[3][50]&#061;{&#034;how&#034;,&#034;are&#034;,&#034;you&#034;};<br \/>\nchar strs1[3][50]&#061;{{&#034;how&#034;},{&#034;are&#034;},{&#034;you&#034;}};<\/p>\n<p>char strs2[3][50]&#061;{0};  \/\/\u5e38\u7528&#xff0c;\u5269\u4f59\u7684\u5168\u90e8\u88650<br \/>\nchar strs3[3][50]&#061;{{0}};<\/p>\n<p>char strs4[][50]&#061;{&#034;hello&#034;,&#034;are&#034;,&#034;you&#034;};\/\/\u7a7a\u7684\u4f4d\u7f6e\u53ea\u4f1a\u4e3a3<\/p>\n<h4 id=\"%E8%AE%BF%E9%97%AE%EF%BC%9A%E8%AF%BB\">\u8bbf\u95ee&#xff1a;\u8bfb<\/h4>\n<p>\/\/\u8bbf\u95ee&#xff0c;\u8bfb<br \/>\nprintf(&#034;%s\\\\n&#034;,strs[0]);       \/\/%s&#8211;&gt;char[]<br \/>\nprintf(&#034;%d\\\\n&#034;,strs[0][0]);    \/\/%s&#8211;&gt;char[]<\/p>\n<p>int i&#061;0;<br \/>\nint hang&#061;sizeof(strs)\/sizeof(strs[0]);  \/\/  150\/50<\/p>\n<p>for(i&#061;0;i&lt;hang;i&#043;&#043;)<br \/>\n{<br \/>\nprintf(&#034;strs[i]:%s\\\\n&#034;,strs[i]);<br \/>\n}<\/p>\n<h4 id=\"%E8%AE%BF%E9%97%AE%EF%BC%9A%E5%86%99\">\u8bbf\u95ee&#xff1a;\u5199<\/h4>\n<p>\/\/\u8bbf\u95ee&#xff0c;\u5199<br \/>\nstrcpy(strs[0],&#034;aaa&#034;);<br \/>\nstrcat(strs[2],&#034;!!!&#034;);<br \/>\nprintf(&#034;\u4fee\u6539\u540e&#xff1a;&#034;);<br \/>\nfor(i&#061;0;i&lt;hang;i&#043;&#043;)<br \/>\n{<br \/>\nprintf(&#034;strs[i]:%s\\\\n&#034;,strs[i]);<br \/>\n}<\/p>\n<h2 id=\"%EF%BC%81%E9%87%8D%E7%82%B9%EF%BC%81\"><span style=\"color:#fe2c24\">&#xff01;\u91cd\u70b9&#xff01;<\/span><\/h2>\n<h4 id=\"%E7%AC%AC%E5%9B%9B%E7%AB%A0\">\u7b2c\u56db\u7ae0<\/h4>\n<p>\u7cfb\u7edf\u63d0\u4f9b\u7684\u76f8\u5173\u64cd\u4f5c\u51fd\u6570<\/p>\n<p>\u719f\u7ec3\u8c03\u7528C\u5e93\u5b57\u7b26&#xff08;strlen\u3001strcat\u3001strcmp\u3001strcpy&#xff09;\u4e32\u76f8\u5173\u51fd\u6570<\/p>\n<p><span style=\"color:#a2e043\">\u624b\u6495\u4ee3\u7801&#xff1a;strlen\u3001strcpy\u3001strcmp\u3001strcat\u3001\u6392\u5e8f<\/span><\/p>\n<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u5f55 \u4e00\u7ef4\u5b57\u7b26\u6570\u7ec4<br \/>\n\u5b57\u7b26\u4e32\u5e38\u7528\u76f8\u5173\u51fd\u6570<br \/>\n\u83b7\u5f97\u5b57\u7b26\u4e32\u957f\u5ea6&#xff08;strlen&#xff09;<br \/>\n\u7cfb\u7edf\u8c03\u7528\u51fd\u6570<br \/>\n\u4e0d\u7528\u7cfb\u7edf\u51fd\u6570<br \/>\n\u5b57\u7b26\u4e32\u590d\u5236\u64cd\u4f5c&#xff08;strcpy&#xff09;<br \/>\n\u7cfb\u7edf\u8c03\u7528\u51fd\u6570<br \/>\n\u4e0d\u7528\u51fd\u6570\u7684\u5b57\u7b26\u4e32\u590d\u5236<br \/>\n\u65b9\u6cd5\u4e00<br \/>\n\u65b9\u6cd5\u4e8c<br \/>\n\u65b9\u6cd5\u4e09<br \/>\n\u5b57\u7b26\u4e32\u7684\u62fc\u63a5\u51fd\u6570&#xff08;strcat&#xff09;<br \/>\n\u7cfb\u7edf\u8c03\u7528\u51fd\u6570<br \/>\n\u4e0d\u7528\u51fd\u6570<br \/>\n\u5b57\u7b26\u4e32\u6bd4\u8f83&#xff08;strcmp&#xff09;<br \/>\n\u7cfb\u7edf\u51fd\u6570<br \/>\n\u4e0d\u7528\u51fd\u6570<br \/>\n\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4<br \/>\n\u5b9a\u4e49\u7684\u8bed\u6cd5<br \/>\n\u521d\u59cb\u5316<\/p>\n","protected":false},"author":2,"featured_media":64594,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[174],"topic":[],"class_list":["post-64595","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C\u8bed\u8a00\u5b57\u7b26\u4e32\u64cd\u4f5c - \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\/64595.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C\u8bed\u8a00\u5b57\u7b26\u4e32\u64cd\u4f5c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u76ee\u5f55 \u4e00\u7ef4\u5b57\u7b26\u6570\u7ec4 \u5b57\u7b26\u4e32\u5e38\u7528\u76f8\u5173\u51fd\u6570 \u83b7\u5f97\u5b57\u7b26\u4e32\u957f\u5ea6&#xff08;strlen&#xff09; \u7cfb\u7edf\u8c03\u7528\u51fd\u6570 \u4e0d\u7528\u7cfb\u7edf\u51fd\u6570 \u5b57\u7b26\u4e32\u590d\u5236\u64cd\u4f5c&#xff08;strcpy&#xff09; \u7cfb\u7edf\u8c03\u7528\u51fd\u6570 \u4e0d\u7528\u51fd\u6570\u7684\u5b57\u7b26\u4e32\u590d\u5236 \u65b9\u6cd5\u4e00 \u65b9\u6cd5\u4e8c \u65b9\u6cd5\u4e09 \u5b57\u7b26\u4e32\u7684\u62fc\u63a5\u51fd\u6570&#xff08;strcat&#xff09; \u7cfb\u7edf\u8c03\u7528\u51fd\u6570 \u4e0d\u7528\u51fd\u6570 \u5b57\u7b26\u4e32\u6bd4\u8f83&#xff08;strcmp&#xff09; \u7cfb\u7edf\u51fd\u6570 \u4e0d\u7528\u51fd\u6570 \u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4 \u5b9a\u4e49\u7684\u8bed\u6cd5 \u521d\u59cb\u5316\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/64595.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-23T11:56:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260123115637-697361f50eefc.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=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/64595.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/64595.html\",\"name\":\"C\u8bed\u8a00\u5b57\u7b26\u4e32\u64cd\u4f5c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-23T11:56:38+00:00\",\"dateModified\":\"2026-01-23T11:56:38+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/64595.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/64595.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/64595.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C\u8bed\u8a00\u5b57\u7b26\u4e32\u64cd\u4f5c\"}]},{\"@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":"C\u8bed\u8a00\u5b57\u7b26\u4e32\u64cd\u4f5c - \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\/64595.html","og_locale":"zh_CN","og_type":"article","og_title":"C\u8bed\u8a00\u5b57\u7b26\u4e32\u64cd\u4f5c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u76ee\u5f55 \u4e00\u7ef4\u5b57\u7b26\u6570\u7ec4 \u5b57\u7b26\u4e32\u5e38\u7528\u76f8\u5173\u51fd\u6570 \u83b7\u5f97\u5b57\u7b26\u4e32\u957f\u5ea6&#xff08;strlen&#xff09; \u7cfb\u7edf\u8c03\u7528\u51fd\u6570 \u4e0d\u7528\u7cfb\u7edf\u51fd\u6570 \u5b57\u7b26\u4e32\u590d\u5236\u64cd\u4f5c&#xff08;strcpy&#xff09; \u7cfb\u7edf\u8c03\u7528\u51fd\u6570 \u4e0d\u7528\u51fd\u6570\u7684\u5b57\u7b26\u4e32\u590d\u5236 \u65b9\u6cd5\u4e00 \u65b9\u6cd5\u4e8c \u65b9\u6cd5\u4e09 \u5b57\u7b26\u4e32\u7684\u62fc\u63a5\u51fd\u6570&#xff08;strcat&#xff09; \u7cfb\u7edf\u8c03\u7528\u51fd\u6570 \u4e0d\u7528\u51fd\u6570 \u5b57\u7b26\u4e32\u6bd4\u8f83&#xff08;strcmp&#xff09; \u7cfb\u7edf\u51fd\u6570 \u4e0d\u7528\u51fd\u6570 \u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4 \u5b9a\u4e49\u7684\u8bed\u6cd5 \u521d\u59cb\u5316","og_url":"https:\/\/www.wsisp.com\/helps\/64595.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-23T11:56:38+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260123115637-697361f50eefc.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/64595.html","url":"https:\/\/www.wsisp.com\/helps\/64595.html","name":"C\u8bed\u8a00\u5b57\u7b26\u4e32\u64cd\u4f5c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-23T11:56:38+00:00","dateModified":"2026-01-23T11:56:38+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/64595.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/64595.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/64595.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"C\u8bed\u8a00\u5b57\u7b26\u4e32\u64cd\u4f5c"}]},{"@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\/64595","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=64595"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/64595\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/64594"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=64595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=64595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=64595"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=64595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}