{"id":79,"date":"2026-09-13T15:47:40","date_gmt":"2026-09-13T07:47:40","guid":{"rendered":"https:\/\/decagrammaton.xyz\/?p=79"},"modified":"2026-09-17T15:50:15","modified_gmt":"2026-09-17T07:50:15","slug":"07-c%e8%af%ad%e8%a8%80%e5%ad%97%e7%ac%a6%e4%b8%b2","status":"publish","type":"post","link":"https:\/\/decagrammaton.xyz\/?p=79","title":{"rendered":"07-C\u8bed\u8a00\u5b57\u7b26\u4e32"},"content":{"rendered":"\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\u5b9a\u4e49\u548c\u7531\u6765<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">C \u8bed\u8a00\u6ca1\u6709\u72ec\u7acb\u7684 string \u5b57\u7b26\u4e32\u7c7b\u578b\u3002C \u8bed\u8a00\u4e2d\u7684\u5b57\u7b26\u4e32\u901a\u5e38\u4f7f\u7528\u4ee5 \u2018\\0\u2019\n\u7ed3\u5c3e\u7684 char \u6570\u7ec4\u8868\u793a\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528\u4f8b:<\/p>\n\n\n\n<div class=\"sourceCode\" id=\"cb1\"><pre class=\"sourceCode c\"><code class=\"sourceCode c\"><span id=\"cb1-1\"><a href=\"#cb1-1\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"dt\">char<\/span> a<span class=\"op\">[]={<\/span><span class=\"ch\">'A'<\/span><span class=\"op\">,<\/span><span class=\"ch\">'B'<\/span><span class=\"op\">,<\/span><span class=\"ch\">'C'<\/span><span class=\"op\">,<\/span><span class=\"ch\">'D'<\/span><span class=\"op\">,<\/span><span class=\"ch\">'<\/span><span class=\"sc\">\\0<\/span><span class=\"ch\">'<\/span><span class=\"op\">};<\/span><\/span>\n<span id=\"cb1-2\"><a href=\"#cb1-2\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"dt\">char<\/span> b<span class=\"op\">[]={<\/span><span class=\"st\">\"hello\"<\/span><span class=\"op\">};<\/span><span class=\"co\">\/\/\u4e24\u4e2a\u90fd\u662fc\u7684\u5408\u6cd5\u5199\u6cd5\uff0c\u662f\u9010\u4e2a\u8f93\u5165\u548c\u5168\u90e8\u8f93\u51652\u79cd\u5199\u6cd5,b\u7c7b\u578b\u7f16\u8bd1\u5668\u4f1a\u81ea\u5df1\u52a0\u5165\"\\0\"<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u5b57\u7b26\u4e32\u7684\u64cd\u4f5c<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b57\u7b26\u4e32\u7684\u64cd\u4f5c<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">C \u8bed\u8a00\u63d0\u4f9b\u4e86 <code>&lt;string.h&gt;<\/code>\n\u5934\u6587\u4ef6\uff0c\u7528\u4e8e\u8fdb\u884c\u5e38\u89c1\u7684\u5b57\u7b26\u4e32\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528\u524d\u9700\u8981\uff1a<\/p>\n\n\n\n<div class=\"sourceCode\" id=\"cb2\"><pre class=\"sourceCode c\"><code class=\"sourceCode c\"><span id=\"cb2-1\"><a href=\"#cb2-1\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"pp\">#include <\/span><span class=\"im\">&lt;string.h&gt;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">\u5e38\u7528\u5b57\u7b26\u4e32\u51fd\u6570<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u51fd\u6570<\/th><th>\u4f5c\u7528<\/th><\/tr><\/thead><tbody><tr><td><code>strlen()<\/code><\/td><td>\u83b7\u53d6\u5b57\u7b26\u4e32\u957f\u5ea6<\/td><\/tr><tr><td><code>strcpy()<\/code><\/td><td>\u590d\u5236\u5b57\u7b26\u4e32<\/td><\/tr><tr><td><code>strcat()<\/code><\/td><td>\u8fde\u63a5\u4e24\u4e2a\u5b57\u7b26\u4e32<\/td><\/tr><tr><td><code>strcmp()<\/code><\/td><td>\u6bd4\u8f83\u4e24\u4e2a\u5b57\u7b26\u4e32<\/td><\/tr><tr><td><code>strchr()<\/code><\/td><td>\u67e5\u627e\u5b57\u7b26\u7b2c\u4e00\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e<\/td><\/tr><tr><td><code>strstr()<\/code><\/td><td>\u67e5\u627e\u5b57\u7b26\u4e32\u7b2c\u4e00\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><code>strlen()<\/code> \u2014\u2014\n\u83b7\u53d6\u5b57\u7b26\u4e32\u957f\u5ea6<\/h3>\n\n\n\n<div class=\"sourceCode\" id=\"cb3\"><pre class=\"sourceCode c\"><code class=\"sourceCode c\"><span id=\"cb3-1\"><a href=\"#cb3-1\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"dt\">char<\/span> a<span class=\"op\">[]<\/span> <span class=\"op\">=<\/span> <span class=\"st\">\"Hello\"<\/span><span class=\"op\">;<\/span><\/span>\n<span id=\"cb3-2\"><a href=\"#cb3-2\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><\/span>\n<span id=\"cb3-3\"><a href=\"#cb3-3\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>printf<span class=\"op\">(<\/span><span class=\"st\">\"<\/span><span class=\"sc\">%zu\\n<\/span><span class=\"st\">\"<\/span><span class=\"op\">,<\/span> strlen<span class=\"op\">(<\/span>a<span class=\"op\">));<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u8f93\u51fa\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>5<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>strlen()<\/code> \u4f1a\u4ece\u5b57\u7b26\u4e32\u5f00\u5934\u5f00\u59cb\u8ba1\u7b97\u5b57\u7b26\u6570\u91cf\uff0c\u76f4\u5230\u9047\u5230\n<code>'\\0'<\/code> \u4e3a\u6b62\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u6ce8\u610f\uff1a<code>'\\0'<\/code> \u4e0d\u8ba1\u7b97\u5728\u5b57\u7b26\u4e32\u957f\u5ea6\u4e2d\u3002<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><code>strcpy()<\/code> \u2014\u2014 \u590d\u5236\u5b57\u7b26\u4e32<\/h3>\n\n\n\n<div class=\"sourceCode\" id=\"cb5\"><pre class=\"sourceCode c\"><code class=\"sourceCode c\"><span id=\"cb5-1\"><a href=\"#cb5-1\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"dt\">char<\/span> a<span class=\"op\">[<\/span><span class=\"dv\">20<\/span><span class=\"op\">];<\/span><\/span>\n<span id=\"cb5-2\"><a href=\"#cb5-2\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"dt\">char<\/span> b<span class=\"op\">[]<\/span> <span class=\"op\">=<\/span> <span class=\"st\">\"Hello\"<\/span><span class=\"op\">;<\/span><\/span>\n<span id=\"cb5-3\"><a href=\"#cb5-3\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><\/span>\n<span id=\"cb5-4\"><a href=\"#cb5-4\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>strcpy<span class=\"op\">(<\/span>a<span class=\"op\">,<\/span> b<span class=\"op\">);<\/span><\/span>\n<span id=\"cb5-5\"><a href=\"#cb5-5\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><\/span>\n<span id=\"cb5-6\"><a href=\"#cb5-6\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>printf<span class=\"op\">(<\/span><span class=\"st\">\"<\/span><span class=\"sc\">%s\\n<\/span><span class=\"st\">\"<\/span><span class=\"op\">,<\/span> a<span class=\"op\">);<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u6267\u884c\u540e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a = \"Hello\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e5f\u5c31\u662f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>strcpy(\u76ee\u6807, \u6e90)<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><code>strcat()<\/code> \u2014\u2014 \u8fde\u63a5\u5b57\u7b26\u4e32<\/h3>\n\n\n\n<div class=\"sourceCode\" id=\"cb8\"><pre class=\"sourceCode c\"><code class=\"sourceCode c\"><span id=\"cb8-1\"><a href=\"#cb8-1\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"dt\">char<\/span> a<span class=\"op\">[<\/span><span class=\"dv\">20<\/span><span class=\"op\">]<\/span> <span class=\"op\">=<\/span> <span class=\"st\">\"Hello \"<\/span><span class=\"op\">;<\/span><\/span>\n<span id=\"cb8-2\"><a href=\"#cb8-2\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"dt\">char<\/span> b<span class=\"op\">[]<\/span> <span class=\"op\">=<\/span> <span class=\"st\">\"World\"<\/span><span class=\"op\">;<\/span><\/span>\n<span id=\"cb8-3\"><a href=\"#cb8-3\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><\/span>\n<span id=\"cb8-4\"><a href=\"#cb8-4\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>strcat<span class=\"op\">(<\/span>a<span class=\"op\">,<\/span> b<span class=\"op\">);<\/span><\/span>\n<span id=\"cb8-5\"><a href=\"#cb8-5\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><\/span>\n<span id=\"cb8-6\"><a href=\"#cb8-6\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>printf<span class=\"op\">(<\/span><span class=\"st\">\"<\/span><span class=\"sc\">%s\\n<\/span><span class=\"st\">\"<\/span><span class=\"op\">,<\/span> a<span class=\"op\">);<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u8f93\u51fa\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Hello World<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e5f\u5c31\u662f\u628a <code>b<\/code> \u8fde\u63a5\u5230 <code>a<\/code> \u7684\u672b\u5c3e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a = \"Hello \" + \"World\"\n  = \"Hello World\"<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u6ce8\u610f\uff1a\u76ee\u6807\u6570\u7ec4\u5fc5\u987b\u6709\u8db3\u591f\u7684\u7a7a\u95f4\u5b58\u653e\u8fde\u63a5\u540e\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><code>strcmp()<\/code> \u2014\u2014 \u6bd4\u8f83\u5b57\u7b26\u4e32<\/h3>\n\n\n\n<div class=\"sourceCode\" id=\"cb11\"><pre class=\"sourceCode c\"><code class=\"sourceCode c\"><span id=\"cb11-1\"><a href=\"#cb11-1\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"dt\">char<\/span> a<span class=\"op\">[]<\/span> <span class=\"op\">=<\/span> <span class=\"st\">\"Hello\"<\/span><span class=\"op\">;<\/span><\/span>\n<span id=\"cb11-2\"><a href=\"#cb11-2\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"dt\">char<\/span> b<span class=\"op\">[]<\/span> <span class=\"op\">=<\/span> <span class=\"st\">\"Hello\"<\/span><span class=\"op\">;<\/span><\/span>\n<span id=\"cb11-3\"><a href=\"#cb11-3\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><\/span>\n<span id=\"cb11-4\"><a href=\"#cb11-4\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>printf<span class=\"op\">(<\/span><span class=\"st\">\"<\/span><span class=\"sc\">%d\\n<\/span><span class=\"st\">\"<\/span><span class=\"op\">,<\/span> strcmp<span class=\"op\">(<\/span>a<span class=\"op\">,<\/span> b<span class=\"op\">));<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u4e24\u4e2a\u5b57\u7b26\u4e32\u5b8c\u5168\u76f8\u540c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>strcmp()<\/code> \u7684\u8fd4\u56de\u503c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>0     \u2192 \u4e24\u4e2a\u5b57\u7b26\u4e32\u76f8\u540c\n&lt; 0   \u2192 s1 \u5c0f\u4e8e s2\n&gt; 0   \u2192 s1 \u5927\u4e8e s2<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6bd4\u8f83\u7684\u662f\u5b57\u7b26\u4e32\u7684\u5b57\u7b26\u987a\u5e8f\uff0c\u800c\u4e0d\u662f\u5b57\u7b26\u4e32\u957f\u5ea6\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><code>strchr()<\/code> \u2014\u2014 \u67e5\u627e\u5b57\u7b26<\/h3>\n\n\n\n<div class=\"sourceCode\" id=\"cb14\"><pre class=\"sourceCode c\"><code class=\"sourceCode c\"><span id=\"cb14-1\"><a href=\"#cb14-1\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"dt\">char<\/span> a<span class=\"op\">[]<\/span> <span class=\"op\">=<\/span> <span class=\"st\">\"Hello\"<\/span><span class=\"op\">;<\/span><\/span>\n<span id=\"cb14-2\"><a href=\"#cb14-2\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><\/span>\n<span id=\"cb14-3\"><a href=\"#cb14-3\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"dt\">char<\/span> <span class=\"op\">*<\/span>p <span class=\"op\">=<\/span> strchr<span class=\"op\">(<\/span>a<span class=\"op\">,<\/span> <span class=\"ch\">'l'<\/span><span class=\"op\">);<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><code>strchr()<\/code>\n\u4f1a\u8fd4\u56de\u4e00\u4e2a\u6307\u9488\uff0c\u6307\u5411\u5b57\u7b26\u4e32\u4e2d<strong>\u7b2c\u4e00\u6b21\u51fa\u73b0\u8be5\u5b57\u7b26\u7684\u4f4d\u7f6e<\/strong>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f8b\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Hello\n  \u2191\n  \u7b2c\u4e00\u6b21\u51fa\u73b0 'l'<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><code>strstr()<\/code> \u2014\u2014 \u67e5\u627e\u5b57\u7b26\u4e32<\/h3>\n\n\n\n<div class=\"sourceCode\" id=\"cb16\"><pre class=\"sourceCode c\"><code class=\"sourceCode c\"><span id=\"cb16-1\"><a href=\"#cb16-1\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"dt\">char<\/span> a<span class=\"op\">[]<\/span> <span class=\"op\">=<\/span> <span class=\"st\">\"Hello World\"<\/span><span class=\"op\">;<\/span><\/span>\n<span id=\"cb16-2\"><a href=\"#cb16-2\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><\/span>\n<span id=\"cb16-3\"><a href=\"#cb16-3\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"dt\">char<\/span> <span class=\"op\">*<\/span>p <span class=\"op\">=<\/span> strstr<span class=\"op\">(<\/span>a<span class=\"op\">,<\/span> <span class=\"st\">\"World\"<\/span><span class=\"op\">);<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><code>strstr()<\/code>\n\u4f1a\u8fd4\u56de\u4e00\u4e2a\u6307\u9488\uff0c\u6307\u5411\u5b57\u7b26\u4e32\u4e2d<strong>\u7b2c\u4e00\u6b21\u51fa\u73b0\u76ee\u6807\u5b57\u7b26\u4e32\u7684\u4f4d\u7f6e<\/strong>\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Hello World\n      \u2191\n    World<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u5c0f\u7ed3<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u5e38\u7528\u7684\u51e0\u4e2a\u5b57\u7b26\u4e32\u51fd\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>strlen()  \u2192 \u83b7\u53d6\u957f\u5ea6\nstrcpy()  \u2192 \u590d\u5236\nstrcat()  \u2192 \u8fde\u63a5\nstrcmp()  \u2192 \u6bd4\u8f83\nstrchr()  \u2192 \u67e5\u627e\u5b57\u7b26\nstrstr()  \u2192 \u67e5\u627e\u5b57\u7b26\u4e32<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e9b\u51fd\u6570\u90fd\u6765\u81ea\uff1a<\/p>\n\n\n\n<div class=\"sourceCode\" id=\"cb19\"><pre class=\"sourceCode c\"><code class=\"sourceCode c\"><span id=\"cb19-1\"><a href=\"#cb19-1\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"pp\">#include <\/span><span class=\"im\">&lt;string.h&gt;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div class=\"tip\">\n<p>\u6ce8\u610f\uff0c\u5b57\u7b26\u4e32\u7ed3\u5c3e\u7684 \u2018\\0\u2019 \u4e0d\u4f1a\u88ab strlen() \u8ba1\u7b97\u3002<\/p>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528\u4f8b:<\/p>\n\n\n\n<div class=\"sourceCode\" id=\"cb20\"><pre class=\"sourceCode c\"><code class=\"sourceCode c\"><span id=\"cb20-1\"><a href=\"#cb20-1\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"pp\">#include <\/span><span class=\"im\">&lt;stdio.h&gt;<\/span><\/span>\n<span id=\"cb20-2\"><a href=\"#cb20-2\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"pp\">#include <\/span><span class=\"im\">&lt;string.h&gt;<\/span><\/span>\n<span id=\"cb20-3\"><a href=\"#cb20-3\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a> <\/span>\n<span id=\"cb20-4\"><a href=\"#cb20-4\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"dt\">int<\/span> main <span class=\"op\">()<\/span><\/span>\n<span id=\"cb20-5\"><a href=\"#cb20-5\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"op\">{<\/span><\/span>\n<span id=\"cb20-6\"><a href=\"#cb20-6\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>   <span class=\"dt\">char<\/span> str1<span class=\"op\">[<\/span><span class=\"dv\">14<\/span><span class=\"op\">]<\/span> <span class=\"op\">=<\/span> <span class=\"st\">\"hello,\"<\/span><span class=\"op\">;<\/span><\/span>\n<span id=\"cb20-7\"><a href=\"#cb20-7\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>   <span class=\"dt\">char<\/span> str2<span class=\"op\">[<\/span><span class=\"dv\">14<\/span><span class=\"op\">]<\/span> <span class=\"op\">=<\/span> <span class=\"st\">\"world\"<\/span><span class=\"op\">;<\/span><\/span>\n<span id=\"cb20-8\"><a href=\"#cb20-8\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>   <span class=\"dt\">char<\/span> str3<span class=\"op\">[<\/span><span class=\"dv\">14<\/span><span class=\"op\">];<\/span><\/span>\n<span id=\"cb20-9\"><a href=\"#cb20-9\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>   <span class=\"dt\">int<\/span>  len <span class=\"op\">;<\/span><\/span>\n<span id=\"cb20-10\"><a href=\"#cb20-10\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a> <\/span>\n<span id=\"cb20-11\"><a href=\"#cb20-11\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>   <span class=\"co\">\/* \u590d\u5236 str1 \u5230 str3 *\/<\/span><\/span>\n<span id=\"cb20-12\"><a href=\"#cb20-12\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>   strcpy<span class=\"op\">(<\/span>str3<span class=\"op\">,<\/span> str1<span class=\"op\">);<\/span><\/span>\n<span id=\"cb20-13\"><a href=\"#cb20-13\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>   printf<span class=\"op\">(<\/span><span class=\"st\">\"strcpy( str3, str1) :  <\/span><span class=\"sc\">%s\\n<\/span><span class=\"st\">\"<\/span><span class=\"op\">,<\/span> str3 <span class=\"op\">);<\/span><\/span>\n<span id=\"cb20-14\"><a href=\"#cb20-14\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a> <\/span>\n<span id=\"cb20-15\"><a href=\"#cb20-15\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>   <span class=\"co\">\/* \u8fde\u63a5 str1 \u548c str2 *\/<\/span><\/span>\n<span id=\"cb20-16\"><a href=\"#cb20-16\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>   strcat<span class=\"op\">(<\/span> str1<span class=\"op\">,<\/span> str2<span class=\"op\">);<\/span><\/span>\n<span id=\"cb20-17\"><a href=\"#cb20-17\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>   printf<span class=\"op\">(<\/span><span class=\"st\">\"strcat( str1, str2):   <\/span><span class=\"sc\">%s\\n<\/span><span class=\"st\">\"<\/span><span class=\"op\">,<\/span> str1 <span class=\"op\">);<\/span><\/span>\n<span id=\"cb20-18\"><a href=\"#cb20-18\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a> <\/span>\n<span id=\"cb20-19\"><a href=\"#cb20-19\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>   <span class=\"co\">\/* \u8fde\u63a5\u540e\uff0cstr1 \u7684\u603b\u957f\u5ea6 *\/<\/span><\/span>\n<span id=\"cb20-20\"><a href=\"#cb20-20\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>   len <span class=\"op\">=<\/span> strlen<span class=\"op\">(<\/span>str1<span class=\"op\">);<\/span><\/span>\n<span id=\"cb20-21\"><a href=\"#cb20-21\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>   printf<span class=\"op\">(<\/span><span class=\"st\">\"strlen(str1) :  <\/span><span class=\"sc\">%d\\n<\/span><span class=\"st\">\"<\/span><span class=\"op\">,<\/span> len <span class=\"op\">);<\/span><\/span>\n<span id=\"cb20-22\"><a href=\"#cb20-22\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a> <\/span>\n<span id=\"cb20-23\"><a href=\"#cb20-23\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>   <span class=\"cf\">return<\/span> <span class=\"dv\">0<\/span><span class=\"op\">;<\/span><\/span>\n<span id=\"cb20-24\"><a href=\"#cb20-24\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a><span class=\"op\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd0\u884c\u7ed3\u679c<\/p>\n\n\n\n<div class=\"sourceCode\" id=\"cb21\"><pre class=\"sourceCode c\"><code class=\"sourceCode c\"><span id=\"cb21-1\"><a href=\"#cb21-1\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>strcpy<span class=\"op\">(<\/span> str3<span class=\"op\">,<\/span> str1<span class=\"op\">)<\/span> <span class=\"op\">:<\/span>  hello<span class=\"op\">,<\/span><\/span>\n<span id=\"cb21-2\"><a href=\"#cb21-2\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>strcat<span class=\"op\">(<\/span> str1<span class=\"op\">,<\/span> str2<span class=\"op\">):<\/span>   hello<span class=\"op\">,<\/span>world<\/span>\n<span id=\"cb21-3\"><a href=\"#cb21-3\" aria-hidden=\"true\" tabindex=\"-1\" target=\"_blank\"  rel=\"nofollow\" ><\/a>strlen<span class=\"op\">(<\/span>str1<span class=\"op\">)<\/span> <span class=\"op\">:<\/span>  <span class=\"dv\">11<\/span><\/span><\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9a\u4e49\u548c\u7531\u6765 C \u8bed\u8a00\u6ca1\u6709\u72ec\u7acb\u7684 string \u5b57\u7b26\u4e32\u7c7b\u578b\u3002C \u8bed\u8a00\u4e2d\u7684\u5b57\u7b26\u4e32\u901a\u5e38\u4f7f\u7528\u4ee5 \u2018\\0\u2019 \u7ed3\u5c3e\u7684 char \u6570\u7ec4\u8868\u793a\u3002 \u4f7f &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-79","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/decagrammaton.xyz\/index.php?rest_route=\/wp\/v2\/posts\/79","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/decagrammaton.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/decagrammaton.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/decagrammaton.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/decagrammaton.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=79"}],"version-history":[{"count":2,"href":"https:\/\/decagrammaton.xyz\/index.php?rest_route=\/wp\/v2\/posts\/79\/revisions"}],"predecessor-version":[{"id":81,"href":"https:\/\/decagrammaton.xyz\/index.php?rest_route=\/wp\/v2\/posts\/79\/revisions\/81"}],"wp:attachment":[{"href":"https:\/\/decagrammaton.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=79"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/decagrammaton.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=79"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/decagrammaton.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=79"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}