{"id":108,"date":"2026-03-19T16:01:57","date_gmt":"2026-03-19T08:01:57","guid":{"rendered":"https:\/\/www.caldm.cn\/?p=108"},"modified":"2026-03-19T16:01:57","modified_gmt":"2026-03-19T08:01:57","slug":"%e5%85%b3%e9%97%ad%e8%ad%a6%e5%91%8a%ef%bc%9a%e8%a7%a3%e5%86%b3%e5%ad%a6%e4%b9%a0c-strcat%e6%97%b6%e9%81%87%e5%88%b0%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/www.caldm.cn\/index.php\/2026\/03\/19\/%e5%85%b3%e9%97%ad%e8%ad%a6%e5%91%8a%ef%bc%9a%e8%a7%a3%e5%86%b3%e5%ad%a6%e4%b9%a0c-strcat%e6%97%b6%e9%81%87%e5%88%b0%e7%9a%84%e9%97%ae%e9%a2%98\/","title":{"rendered":"\u5173\u95ed\u8b66\u544a\uff1a\u89e3\u51b3\u5b66\u4e60C strcat()\u65f6\u9047\u5230\u7684\u95ee\u9898"},"content":{"rendered":"\n<p>\u5728\u5b66\u4e60\u4f7f\u7528<code>strcat()<\/code>\u51fd\u6570\u65f6\u9047\u5230\u62a5\u9519\uff0c\u7a0b\u5e8f\u65e0\u6cd5\u8fd0\u884c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n#include &lt;string.h>\n\nint main() {\n    char s1&#91;20] = \"123\";\n    char s2&#91;10] = \"456\";\n    printf(\"s1: %-10s s2: %-10s\\n\", s1, s2);\n    strcat(s1, s2);\n    printf(\"s1: %-10s s2: %-10s\\n\", s1, s2);\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p>\u9519\u8bef\u4ee3\u7801\uff1aC4996<\/p>\n\n\n\n<p>\u9519\u8bef\u8bf4\u660e\uff1a&#8217;strcat&#8217;: This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for detail.<\/p>\n\n\n\n<p>\u8fd9\u4e9b\u4fe1\u606f\u7684\u610f\u601d\u662f<code>strcat<\/code>\u51fd\u6570\u88ab\u8ba4\u4e3a\u662f\u4e0d\u5b89\u5168\u7684\uff0c\u7f16\u8bd1\u5668\u5efa\u8bae\u6211\u4eec\u4f7f\u7528<code>strcat_s<\/code>\u4ee3\u66ff\uff0c\u82e5\u8981\u7981\u7528\u8fd9\u4e2a\u8b66\u544a\uff0c\u53ef\u4ee5\u4f7f\u7528<code>_CRT_SECURE_NO_WARNINGS<\/code>\u3002<\/p>\n\n\n\n<p>\u4f46\u6211\u5c1d\u8bd5\u7528<code>_CRT_SECURE_NO_WARNINGS<\/code>\uff0c\u53d1\u73b0\u8fd8\u662f\u4e0d\u884c\uff0c\u4e8e\u662f\u641c\u7d22\u9519\u8bef\u4ee3\u7801C 4996\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/learn.microsoft.com\/zh-cn\/cpp\/error-messages\/compiler-warnings\/compiler-warning-level-3-c4996?view=msvc-170\">\u7f16\u8bd1\u5668\u8b66\u544a\uff08\u7ea7\u522b 3\uff09 C4996 | Microsoft Learn<\/a><\/p>\n\n\n\n<p>\u8be5\u7f51\u9875\u63d0\u4f9b\u4e86\u4e0d\u540c\u7ea7\u522b\u7684\u5173\u95ed\u8be5\u8b66\u544a\u7684\u65b9\u5f0f\uff0c\u6211\u5728\u4ee3\u7801\u4e2d\u6dfb\u52a0<code>#pragma warning(disable : 4996)<\/code>\u540e\uff0c\u7a0b\u5e8f\u6210\u529f\u8fd0\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u5b66\u4e60\u4f7f\u7528strcat()\u51fd\u6570\u65f6\u9047\u5230\u62a5\u9519\uff0c\u7a0b\u5e8f\u65e0\u6cd5\u8fd0\u884c\u3002 \u9519\u8bef\u4ee3\u7801\uff1aC4996 \u9519\u8bef\u8bf4\u660e\uff1a&#8217;str [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[22],"class_list":["post-108","post","type-post","status-publish","format-standard","hentry","category-c-2","tag-debug"],"_links":{"self":[{"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/posts\/108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/comments?post=108"}],"version-history":[{"count":1,"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/posts\/108\/revisions"}],"predecessor-version":[{"id":109,"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/posts\/108\/revisions\/109"}],"wp:attachment":[{"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/media?parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/categories?post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/tags?post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}