{"id":98,"date":"2008-09-10T18:37:39","date_gmt":"2008-09-10T10:37:39","guid":{"rendered":"http:\/\/percy.blog.ubuntu.org.cn\/2008\/09\/10\/%e8%bd%acc%e8%af%ad%e8%a8%80%e5%86%85%e5%ad%98%e5%88%86%e9%85%8d%e9%97%ae%e9%a2%98\/"},"modified":"2018-12-07T23:15:03","modified_gmt":"2018-12-07T15:15:03","slug":"%e8%bd%acc%e8%af%ad%e8%a8%80%e5%86%85%e5%ad%98%e5%88%86%e9%85%8d%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/pjq.me\/?p=98","title":{"rendered":"[\u8f6c]C\u8bed\u8a00\u5185\u5b58\u5206\u914d\u95ee\u9898"},"content":{"rendered":"<h1>C\u8bed\u8a00\u5185\u5b58\u5206\u914d\u95ee\u9898<\/h1>\n<p>http:\/\/www.diybl.com\/course\/3_program\/c\/c_js\/2008611\/124628.html<\/p>\n<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\">\n<tr>\n<td>\n<p align=\"left\">1\u3001C\u4e2d\u5185\u5b58\u5206\u4e3a\u56db\u4e2a\u533a<\/p>\n<ol>\n<li>\u6808\uff1a\u7528\u6765\u5b58\u653e\u51fd\u6570\u7684\u5f62\u53c2\u548c\u51fd\u6570\u5185\u7684\u5c40\u90e8\u53d8\u91cf\u3002\u7531\u7f16\u8bd1\u5668\u5206\u914d\u7a7a\u95f4\uff0c\u5728\u51fd\u6570\u6267\u884c\u5b8c\u540e\u7531\u7f16\u8bd1\u5668\u81ea\u52a8\u91ca\u653e\u3002<\/li>\n<li>\u5806\uff1a\u7528\u6765\u5b58\u653e\u7531\u52a8\u6001\u5206\u914d\u51fd\u6570\uff08\u5982malloc\uff09\u5206\u914d\u7684\u7a7a\u95f4\u3002\u662f\u7531\u7a0b\u5e8f\u5458\u81ea\u5df1\u624b\u52a8\u5206\u914d\u7684\uff0c\u5e76\u4e14\u5fc5\u987b\u7531\u7a0b\u5e8f\u5458\u4f7f\u7528free\u91ca\u653e\u3002\u5982\u679c\u5fd8\u8bb0\u7528free\u91ca\u653e\uff0c\u4f1a\u5bfc\u81f4\u6240\u5206\u914d\u7684\u7a7a\u95f4\u4e00\u76f4\u5360\u7740\u4e0d\u653e\uff0c\u5bfc\u81f4\u5185\u5b58\u6cc4\u9732\u3002<\/li>\n<li>\u5168\u5c40\u5c40\uff1a\u7528\u6765\u5b58\u653e\u5168\u5c40\u53d8\u91cf\u548c\u9759\u6001\u53d8\u91cf\u3002\u5b58\u5728\u4e8e\u7a0b\u5e8f\u7684\u6574\u4e2a\u8fd0\u884c\u671f\u95f4\uff0c\u662f\u7531\u7f16\u8bd1\u5668\u5206\u914d\u548c\u91ca\u653e\u7684\u3002<\/li>\n<li>\u6587\u5b57\u5e38\u91cf\u533a\uff1a\u4f8b\u5982char *c = \u201c123456\u201d\uff1b\u5219\u201d123456\u201d\u4e3a\u6587\u5b57\u5e38\u91cf\uff0c\u5b58\u653e\u4e8e\u6587\u5b57\u5e38\u91cf\u533a\u3002\u4e5f\u7531\u7f16\u8bd1\u5668\u63a7\u5236\u5206\u914d\u548c\u91ca\u653e\u3002<\/li>\n<li>\u7a0b\u5e8f\u4ee3\u7801\u533a\uff1a\u7528\u6765\u5b58\u653e\u7a0b\u5e8f\u7684\u4e8c\u8fdb\u5236\u4ee3\u7801\u3002<\/li>\n<\/ol>\n<p align=\"left\">\u4f8b\u5b50(\u4e00)<\/p>\n<p align=\"left\">int a = 0; \/\/\u5168\u5c40\u533a<\/p>\n<p align=\"left\">void main()<\/p>\n<p align=\"left\">{<\/p>\n<p align=\"left\">int b; \/\/\u6808<\/p>\n<p align=\"left\">char s[] = abc; \/\/s\u5728\u6808,abc\u5728\u6587\u5b57\u5e38\u91cf\u533a<\/p>\n<p align=\"left\">char *p1,*p2; \/\/\u6808<\/p>\n<p align=\"left\">char *p3 = &#8220;123456&#8221;; \/\/123456\u5728\u5e38\u91cf\u533a\uff0cp3\u5728\u6808\u4e0a<\/p>\n<p align=\"left\">static int c =0; \/\/\u5168\u5c40\u533a<\/p>\n<p align=\"left\">p1 = (char *)malloc(10); \/\/p1\u5728\u6808\uff0c\u5206\u914d\u768410\u5b57\u8282\u5728\u5806<\/p>\n<p align=\"left\">p2 = (char *)malloc(20); \/\/p2\u5728\u6808\uff0c\u5206\u914d\u768420\u5b57\u8282\u5728\u5806<\/p>\n<p align=\"left\">strcpy(p1, &#8220;123456&#8221;); \/\/123456\u653e\u5728\u5e38\u91cf\u533a<\/p>\n<p align=\"left\">}<\/p>\n<p align=\"left\">\u4f8b\u5b50(\u4e8c)<\/p>\n<p align=\"left\">\/\/\u8fd4\u56dechar\u578b\u6307\u9488<\/p>\n<p align=\"left\">char *f()<\/p>\n<p align=\"left\">{<\/p>\n<p align=\"left\">\/\/s\u6570\u7ec4\u5b58\u653e\u4e8e\u6808\u4e0a<\/p>\n<p align=\"left\">char s[4] = {&#8216;1&#8242;,&#8217;2&#8242;,&#8217;3&#8242;,&#8217;0&#8217;};<\/p>\n<p align=\"left\">return s; \/\/\u8fd4\u56des\u6570\u7ec4\u7684\u5730\u5740\uff0c\u4f46\u7a0b\u5e8f\u8fd0\u884c\u5b8cs\u6570\u7ec4\u5c31\u88ab\u91ca\u653e\u4e86<\/p>\n<p align=\"left\">}<\/p>\n<p align=\"left\">void main()<\/p>\n<p align=\"left\">{<\/p>\n<p align=\"left\">char *s;<\/p>\n<p align=\"left\">s = f();<\/p>\n<p align=\"left\">printf (%s, s); \/\/\u6253\u5370\u51fa\u6765\u4e71\u7801\u3002\u56e0\u4e3as\u6240\u6307\u5411\u5730\u5740\u5df2\u7ecf\u6ca1\u6709\u6570\u636e<\/p>\n<p align=\"left\">}<\/p>\n<p align=\"left\">2\u3001\u52a8\u6001\u5206\u914d\u91ca\u653e\u5185\u5b58<\/p>\n<ol>\n<li>\u7528malloc\u52a8\u6001\u5206\u914d\u5185\u5b58\u540e\u4e00\u5b9a\u8981\u5224\u65ad\u4e00\u4e0b\u5206\u914d\u662f\u5426\u6210\u529f\uff0c\u5224\u65ad\u6307\u9488\u7684\u503c\u662f\u5426\u4e3aNULL\u3002<\/li>\n<li>\u5185\u5b58\u5206\u914d\u6210\u529f\u540e\u8981\u5bf9\u5185\u5b58\u5355\u5143\u8fdb\u884c\u521d\u59cb\u5316\u3002<\/li>\n<li>\u5185\u5b58\u5206\u914d\u6210\u529f\u4e14\u521d\u59cb\u5316\u540e\u4f7f\u7528\u65f6\u522b\u8d8a\u754c\u4e86\u3002<\/li>\n<li>\u5185\u5b58\u4f7f\u7528\u5b8c\u540e\u8981\u7528free\uff08p\uff09\u91ca\u653e\uff0c\u6ce8\u610f\uff0c\u91ca\u653e\u540e\uff0cp\u7684\u503c\u662f\u4e0d\u4f1a\u53d8\u7684\uff0c\u4ecd\u7136\u662f\u4e00\u4e2a\u5730\u5740\u503c\uff0c\u4ecd\u7136\u6307\u5411\u90a3\u5757\u5185\u5b58\u533a\uff0c\u53ea\u662f\u8fd9\u5757\u5185\u5b58\u533a\u7684\u503c\u53d8\u6210\u5783\u573e\u4e86\u3002\u4e3a\u4e86\u9632\u6b62\u540e\u9762\u7ee7\u7eed\u4f7f\u7528\u8fd9\u5757\u5185\u5b58\uff0c\u5e94\u5728free(p)\u540e\uff0c\u7acb\u5373p=NULL\uff0c\u8fd9\u6837\u540e\u9762\u5982\u679c\u8981\u4f7f\u7528\uff0c\u5224\u65adp\u662f\u5426\u4e3aNULL\u65f6\u5c31\u4f1a\u5224\u65ad\u51fa\u6765\u3002<\/li>\n<\/ol>\n<p>NO.1<\/p>\n<p>void GetMemory(char *p)<br \/>\n{<br \/>\np = (char *)malloc(100);<br \/>\n}<\/p>\n<p>void  Test(void)<br \/>\n{<br \/>\nchar *str = NULL;<br \/>\nGetMemory(str);<br \/>\nstrcpy(str,&#8221;hello world&#8221;);<br \/>\nprintf(str);<br \/>\n}<br \/>\n\u8bf7\u95ee\u8fd0\u884cTest\u51fd\u6570\u540e\u4f1a\u662f\u4ec0\u4e48\u6837\u7684\u7ed3\u679c\uff1f<\/p>\n<p>NO.2<br \/>\nchar  *GetMemory(void)<br \/>\n{<br \/>\nchar p[] = &#8220;hello world&#8221;;<br \/>\nretrun  p;<br \/>\n}<\/p>\n<p>void Test(void)<br \/>\n{<br \/>\nchar *str = NULL;<br \/>\nstr =  GetMemory();<br \/>\nprintf(str);<br \/>\n}<br \/>\n\u95ee\u9898\u540cNO.1<\/p>\n<p>NO.3<br \/>\nvoid  GetMemory2(char **p, int num)<br \/>\n{<br \/>\n*p = (char  *)malloc(num);<br \/>\n}<\/p>\n<p>void Test(void)<br \/>\n{<br \/>\nchar *str = NULL;<br \/>\nGetMemory(&amp;str,100);<br \/>\nstrcpy(str,hello);<br \/>\nprintf(str);<br \/>\n}<br \/>\n\u95ee\u9898\u540cNO.1<\/p>\n<p>NO.4<br \/>\nvoid Test(void)<br \/>\n{<br \/>\nchar *str  = (char *)malloc(100);<br \/>\nstrcpy(str,&#8221;hello&#8221;);<br \/>\nfree(str);<br \/>\nif(str  != NULL)<br \/>\n{<br \/>\nstrcpy(str,world);<br \/>\nprintf(str);<br \/>\n}<br \/>\n}<br \/>\n\u95ee\u9898\u540cNO.1<\/p>\n<p>\u6211\u5bf9\u4ee5\u4e0a\u95ee\u9898\u7684\u5206\u6790\uff1a<br \/>\nNO.1\uff1a\u7a0b\u5e8f\u9996\u5148\u7533\u8bf7\u4e00\u4e2achar\u7c7b\u578b\u7684\u6307\u9488str,\u5e76\u628astr\u6307\u5411NULL\uff08\u5373str\u91cc\u5b58\u7684\u662fNULL\u7684\u5730\u5740\uff0c*str\u4e3aNULL\u4e2d\u7684\u503c\u4e3a\uff10\uff09\uff0c\u8c03\u7528\u51fd\u6570\u7684\u8fc7\u7a0b\u4e2d\u505a\u4e86\u5982\u4e0b\u52a8\u4f5c\uff1a\uff11\u7533\u8bf7\u4e00\u4e2achar  \u7c7b\u578b\u7684\u6307\u9488p\uff0c\uff12\u628astr\u7684\u5185\u5bb9copy\u5230\u4e86p\u91cc\uff08\u8fd9\u662f\u53c2\u6570\u4f20\u9012\u8fc7\u7a0b\u4e2d\u7cfb\u7edf\u6240\u505a\u7684\uff09,3\u4e3ap\u6307\u9488\u7533\u8bf7\u4e86100\u4e2a\u7a7a\u95f4\uff0c\uff14\u8fd4\u56deTest\u51fd\u6570\uff0e\u6700\u540e\u7a0b\u5e8f\u628a\u5b57\u7b26\u4e32hello  world\u62f7\u8d1d\u5230str\u6307\u5411\u7684\u5185\u5b58\u7a7a\u95f4\u91cc\uff0e\u5230\u8fd9\u91cc\u9519\u8bef\u51fa\u73b0\u4e86\uff01str\u7684\u7a7a\u95f4\u59cb\u7ec8\u4e3aNULL\u800c\u5e76\u6ca1\u6709\u5b9e\u9645\u7684\u7a7a\u95f4\uff0e\u6df1\u523b\u7406\u89e3\u51fd\u6570\u8c03\u7528\u7684\u7b2c2\u6b65\uff0c\u5c06\u4e0d\u96be\u53d1\u73b0\u95ee\u9898\u6240\u5728\uff01\uff08\u5efa\u8bae\uff1a\u753b\u56fe\u7406\u89e3\uff09<\/p>\n<p>NO.2\uff1a\u7a0b\u5e8f\u9996\u5148\u7533\u8bf7\u4e00\u4e2achar\u7c7b\u578b\u7684\u6307\u9488str,\u5e76\u628astr\u6307\u5411NULL\uff0e\u8c03\u7528\u51fd\u6570\u7684\u8fc7\u7a0b\u4e2d\u505a\u4e86\u5982\u4e0b\u52a8\u4f5c\uff1a\uff11\u7533\u8bf7\u4e00\u6570\u7ec4p[]\u5e76\u5c06\u5176\u8d4b\u503c\u4e3ahello  world(\u6570\u7ec4\u7684\u7a7a\u95f4\u5927\u5c0f\u4e3a12)\uff0c\uff12\u8fd4\u56de\u6570\u7ec4\u540dp\u4ed8\u7ed9str\u6307\u9488\uff08\u5373\u8fd4\u56de\u4e86\u6570\u7ec4\u7684\u9996\u5730\u5740\uff09\uff0e\u90a3\u4e48\u8fd9\u6837\u5c31\u53ef\u4ee5\u6253\u5370\u51fa\u5b57\u7b26\u4e32\uff02hello  world\uff02\u4e86\u4e48\uff1f\u5f53\u7136\u662f\u4e0d\u80fd\u7684\uff01\u56e0\u4e3a\u5728\u51fd\u6570\u8c03\u7528\u7684\u65f6\u5019\u6f0f\u6389\u4e86\u6700\u540e\u4e00\u6b65\uff0e\u4e5f\u5c31\u662f\u5728\u7b2c\uff12\u6b65return\u6570\u7ec4\u540d\u540e\uff0c\u51fd\u6570\u8c03\u7528\u8fd8\u8981\u8fdb\u884c\u4e00\u6b65\u64cd\u4f5c\uff0c\u4e5f\u5c31\u662f\u91ca\u653e\u5185\u5b58\u7a7a\u95f4\uff0e\u5f53\u4e00\u4e2a\u51fd\u6570\u88ab\u8c03\u7528\u7ed3\u675f\u540e\u5b83\u4f1a\u91ca\u653e\u6389\u5b83\u91cc\u9762\u6240\u6709\u7684\u53d8\u91cf\u6240\u5360\u7528\u7684\u7a7a\u95f4\uff0e\u6240\u4ee5\u6570\u7ec4\u7a7a\u95f4\u88ab\u91ca\u653e\u6389\u4e86\uff0c\u4e5f\u5c31\u662f\u8bf4str\u6240\u6307\u5411\u7684\u5185\u5bb9\u5c06\u4e0d\u786e\u5b9a\u662f\u4ec0\u4e48\u4e1c\u897f\uff0e<\/p>\n<p>NO.3\uff1a\u6b63\u786e\u7b54\u6848\u4e3a\u53ef\u4ee5\u6253\u5370\u51fahello\uff0e\u4f46\u5185\u5b58\u6cc4\u6f0f\u4e86\uff01<\/p>\n<p>NO.4\uff1a\u7533\u8bf7\u7a7a\u95f4\uff0c\u62f7\u8d1d\u5b57\u7b26\u4e32\uff0c\u91ca\u653e\u7a7a\u95f4\uff0e\u524d\u4e09\u6b65\u64cd\u4f5c\u90fd\u6ca1\u6709\u4efb\u4f55\u95ee\u9898\uff0e\u5230if\u8bed\u53e5\u91cc\u7684\u5224\u65ad\u6761\u4ef6\u5f00\u59cb\u51fa\u9519\u4e86\uff0c\u56e0\u4e3a\u4e00\u4e2a\u6307\u9488\u88ab\u91ca\u653e\u4e4b\u540e\u5176\u5185\u5bb9\u5e76\u4e0d\u662fNULL\uff0c\u800c\u662f\u4e00\u4e2a\u4e0d\u786e\u5b9a\u7684\u503c\uff0e\u6240\u4ee5if\u8bed\u53e5\u6c38\u8fdc\u90fd\u4e0d\u80fd\u88ab\u6267\u884c\uff0e\u8fd9\u4e5f\u662f\u8457\u540d\u7684\uff02\u91ce\uff02\u6307\u9488\u95ee\u9898\uff0e\u6240\u4ee5\u6211\u4eec\u5728\u7f16\u5199\u7a0b\u5e8f\u91ca\u653e\u4e00\u4e2a\u6307\u9488\u4e4b\u540e\u4e00\u5b9a\u8981\u4eba\u4e3a\u7684\u5c06\u6307\u9488\u4ed8\u6210NULL\uff0e\u8fd9\u6837\u5c31\u4f1a\u907f\u514d\u51fa\u73b0\uff02\u91ce\uff02\u6307\u9488\u7684\u51fa\u73b0\uff0e\u6709\u4eba\u8bf4\uff02\u91ce\uff02\u6307\u9488\u5f88\u53ef\u6015\uff0c\u4f1a\u5e26\u6765\u610f\u60f3\u4e0d\u5230\u7684\u9519\u8bef\uff0e<\/td>\n<\/tr>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>C\u8bed\u8a00\u5185\u5b58\u5206\u914d\u95ee\u9898 http:\/\/www.diybl.com\/course\/3_program\/c\/c_js\/2008611\/124628.html 1\u3001C\u4e2d\u5185\u5b58\u5206\u4e3a\u56db\u4e2a\u533a \u6808\uff1a\u7528\u6765\u5b58\u653e\u51fd\u6570\u7684\u5f62\u53c2\u548c\u51fd\u6570\u5185\u7684\u5c40\u90e8\u53d8\u91cf\u3002\u7531\u7f16\u8bd1\u5668\u5206\u914d\u7a7a\u95f4\uff0c\u5728\u51fd\u6570\u6267\u884c\u5b8c\u540e\u7531\u7f16\u8bd1\u5668\u81ea\u52a8\u91ca\u653e\u3002 \u5806\uff1a\u7528\u6765\u5b58\u653e\u7531\u52a8\u6001\u5206\u914d\u51fd\u6570\uff08\u5982malloc\uff09\u5206\u914d\u7684\u7a7a\u95f4\u3002\u662f\u7531\u7a0b\u5e8f\u5458\u81ea\u5df1\u624b\u52a8\u5206\u914d\u7684\uff0c\u5e76\u4e14\u5fc5\u987b\u7531\u7a0b\u5e8f\u5458\u4f7f\u7528free\u91ca\u653e\u3002\u5982\u679c\u5fd8\u8bb0\u7528free\u91ca\u653e\uff0c\u4f1a\u5bfc\u81f4\u6240\u5206\u914d\u7684\u7a7a\u95f4\u4e00\u76f4\u5360\u7740\u4e0d\u653e\uff0c\u5bfc\u81f4\u5185\u5b58\u6cc4\u9732\u3002 \u5168\u5c40\u5c40\uff1a\u7528\u6765\u5b58\u653e\u5168\u5c40\u53d8\u91cf\u548c\u9759\u6001\u53d8\u91cf\u3002\u5b58\u5728\u4e8e\u7a0b\u5e8f\u7684\u6574\u4e2a\u8fd0\u884c\u671f\u95f4\uff0c\u662f\u7531\u7f16\u8bd1\u5668\u5206\u914d\u548c\u91ca\u653e\u7684\u3002 \u6587\u5b57\u5e38\u91cf\u533a\uff1a\u4f8b\u5982char *c = \u201c123456\u201d\uff1b\u5219\u201d123456\u201d\u4e3a\u6587\u5b57\u5e38\u91cf\uff0c\u5b58\u653e\u4e8e\u6587\u5b57\u5e38\u91cf\u533a\u3002\u4e5f\u7531\u7f16\u8bd1\u5668\u63a7\u5236\u5206\u914d\u548c\u91ca\u653e\u3002 \u7a0b\u5e8f\u4ee3\u7801\u533a\uff1a\u7528\u6765\u5b58\u653e\u7a0b\u5e8f\u7684\u4e8c\u8fdb\u5236\u4ee3\u7801\u3002 \u4f8b\u5b50(\u4e00) int a = 0; \/\/\u5168\u5c40\u533a void main() { int b; \/\/\u6808 char s[] = abc; \/\/s\u5728\u6808,abc\u5728\u6587\u5b57\u5e38\u91cf\u533a char *p1,*p2; \/\/\u6808 char *p3 = &#8220;123456&#8221;; \/\/123456\u5728\u5e38\u91cf\u533a\uff0cp3\u5728\u6808\u4e0a static int c =0;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[169],"tags":[],"class_list":["post-98","post","type-post","status-publish","format-standard","hentry","category-tech"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>[\u8f6c]C\u8bed\u8a00\u5185\u5b58\u5206\u914d\u95ee\u9898 - Jianqing&#039;s Blog<\/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:\/\/pjq.me\/?p=98\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[\u8f6c]C\u8bed\u8a00\u5185\u5b58\u5206\u914d\u95ee\u9898 - Jianqing&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"C\u8bed\u8a00\u5185\u5b58\u5206\u914d\u95ee\u9898 http:\/\/www.diybl.com\/course\/3_program\/c\/c_js\/2008611\/124628.html 1\u3001C\u4e2d\u5185\u5b58\u5206\u4e3a\u56db\u4e2a\u533a \u6808\uff1a\u7528\u6765\u5b58\u653e\u51fd\u6570\u7684\u5f62\u53c2\u548c\u51fd\u6570\u5185\u7684\u5c40\u90e8\u53d8\u91cf\u3002\u7531\u7f16\u8bd1\u5668\u5206\u914d\u7a7a\u95f4\uff0c\u5728\u51fd\u6570\u6267\u884c\u5b8c\u540e\u7531\u7f16\u8bd1\u5668\u81ea\u52a8\u91ca\u653e\u3002 \u5806\uff1a\u7528\u6765\u5b58\u653e\u7531\u52a8\u6001\u5206\u914d\u51fd\u6570\uff08\u5982malloc\uff09\u5206\u914d\u7684\u7a7a\u95f4\u3002\u662f\u7531\u7a0b\u5e8f\u5458\u81ea\u5df1\u624b\u52a8\u5206\u914d\u7684\uff0c\u5e76\u4e14\u5fc5\u987b\u7531\u7a0b\u5e8f\u5458\u4f7f\u7528free\u91ca\u653e\u3002\u5982\u679c\u5fd8\u8bb0\u7528free\u91ca\u653e\uff0c\u4f1a\u5bfc\u81f4\u6240\u5206\u914d\u7684\u7a7a\u95f4\u4e00\u76f4\u5360\u7740\u4e0d\u653e\uff0c\u5bfc\u81f4\u5185\u5b58\u6cc4\u9732\u3002 \u5168\u5c40\u5c40\uff1a\u7528\u6765\u5b58\u653e\u5168\u5c40\u53d8\u91cf\u548c\u9759\u6001\u53d8\u91cf\u3002\u5b58\u5728\u4e8e\u7a0b\u5e8f\u7684\u6574\u4e2a\u8fd0\u884c\u671f\u95f4\uff0c\u662f\u7531\u7f16\u8bd1\u5668\u5206\u914d\u548c\u91ca\u653e\u7684\u3002 \u6587\u5b57\u5e38\u91cf\u533a\uff1a\u4f8b\u5982char *c = \u201c123456\u201d\uff1b\u5219\u201d123456\u201d\u4e3a\u6587\u5b57\u5e38\u91cf\uff0c\u5b58\u653e\u4e8e\u6587\u5b57\u5e38\u91cf\u533a\u3002\u4e5f\u7531\u7f16\u8bd1\u5668\u63a7\u5236\u5206\u914d\u548c\u91ca\u653e\u3002 \u7a0b\u5e8f\u4ee3\u7801\u533a\uff1a\u7528\u6765\u5b58\u653e\u7a0b\u5e8f\u7684\u4e8c\u8fdb\u5236\u4ee3\u7801\u3002 \u4f8b\u5b50(\u4e00) int a = 0; \/\/\u5168\u5c40\u533a void main() { int b; \/\/\u6808 char s[] = abc; \/\/s\u5728\u6808,abc\u5728\u6587\u5b57\u5e38\u91cf\u533a char *p1,*p2; \/\/\u6808 char *p3 = &#8220;123456&#8221;; \/\/123456\u5728\u5e38\u91cf\u533a\uff0cp3\u5728\u6808\u4e0a static int c =0;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/pjq.me\/?p=98\" \/>\n<meta property=\"og:site_name\" content=\"Jianqing&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2008-09-10T10:37:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-12-07T15:15:03+00:00\" \/>\n<meta name=\"author\" content=\"pengjianqing\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"pengjianqing\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/pjq.me\/?p=98#article\",\"isPartOf\":{\"@id\":\"https:\/\/pjq.me\/?p=98\"},\"author\":{\"name\":\"pengjianqing\",\"@id\":\"https:\/\/pjq.me\/#\/schema\/person\/0eb1e72d1e69fbbd9b5c0bfd8e2aae60\"},\"headline\":\"[\u8f6c]C\u8bed\u8a00\u5185\u5b58\u5206\u914d\u95ee\u9898\",\"datePublished\":\"2008-09-10T10:37:39+00:00\",\"dateModified\":\"2018-12-07T15:15:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/pjq.me\/?p=98\"},\"wordCount\":213,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/pjq.me\/#\/schema\/person\/0eb1e72d1e69fbbd9b5c0bfd8e2aae60\"},\"articleSection\":[\"Tech\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/pjq.me\/?p=98#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/pjq.me\/?p=98\",\"url\":\"https:\/\/pjq.me\/?p=98\",\"name\":\"[\u8f6c]C\u8bed\u8a00\u5185\u5b58\u5206\u914d\u95ee\u9898 - Jianqing&#039;s Blog\",\"isPartOf\":{\"@id\":\"https:\/\/pjq.me\/#website\"},\"datePublished\":\"2008-09-10T10:37:39+00:00\",\"dateModified\":\"2018-12-07T15:15:03+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/pjq.me\/?p=98#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/pjq.me\/?p=98\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/pjq.me\/?p=98#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/pjq.me\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[\u8f6c]C\u8bed\u8a00\u5185\u5b58\u5206\u914d\u95ee\u9898\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/pjq.me\/#website\",\"url\":\"https:\/\/pjq.me\/\",\"name\":\"Jianqing&#039;s Blog\",\"description\":\"Thoughts and Future\",\"publisher\":{\"@id\":\"https:\/\/pjq.me\/#\/schema\/person\/0eb1e72d1e69fbbd9b5c0bfd8e2aae60\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/pjq.me\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/pjq.me\/#\/schema\/person\/0eb1e72d1e69fbbd9b5c0bfd8e2aae60\",\"name\":\"pengjianqing\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/pjq.me\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/pjq.me\/wp-content\/uploads\/2021\/12\/Screen-Shot-2021-12-02-at-6.10.58-PM.png\",\"contentUrl\":\"https:\/\/pjq.me\/wp-content\/uploads\/2021\/12\/Screen-Shot-2021-12-02-at-6.10.58-PM.png\",\"width\":460,\"height\":752,\"caption\":\"pengjianqing\"},\"logo\":{\"@id\":\"https:\/\/pjq.me\/#\/schema\/person\/image\/\"},\"url\":\"https:\/\/pjq.me\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[\u8f6c]C\u8bed\u8a00\u5185\u5b58\u5206\u914d\u95ee\u9898 - Jianqing&#039;s Blog","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:\/\/pjq.me\/?p=98","og_locale":"en_US","og_type":"article","og_title":"[\u8f6c]C\u8bed\u8a00\u5185\u5b58\u5206\u914d\u95ee\u9898 - Jianqing&#039;s Blog","og_description":"C\u8bed\u8a00\u5185\u5b58\u5206\u914d\u95ee\u9898 http:\/\/www.diybl.com\/course\/3_program\/c\/c_js\/2008611\/124628.html 1\u3001C\u4e2d\u5185\u5b58\u5206\u4e3a\u56db\u4e2a\u533a \u6808\uff1a\u7528\u6765\u5b58\u653e\u51fd\u6570\u7684\u5f62\u53c2\u548c\u51fd\u6570\u5185\u7684\u5c40\u90e8\u53d8\u91cf\u3002\u7531\u7f16\u8bd1\u5668\u5206\u914d\u7a7a\u95f4\uff0c\u5728\u51fd\u6570\u6267\u884c\u5b8c\u540e\u7531\u7f16\u8bd1\u5668\u81ea\u52a8\u91ca\u653e\u3002 \u5806\uff1a\u7528\u6765\u5b58\u653e\u7531\u52a8\u6001\u5206\u914d\u51fd\u6570\uff08\u5982malloc\uff09\u5206\u914d\u7684\u7a7a\u95f4\u3002\u662f\u7531\u7a0b\u5e8f\u5458\u81ea\u5df1\u624b\u52a8\u5206\u914d\u7684\uff0c\u5e76\u4e14\u5fc5\u987b\u7531\u7a0b\u5e8f\u5458\u4f7f\u7528free\u91ca\u653e\u3002\u5982\u679c\u5fd8\u8bb0\u7528free\u91ca\u653e\uff0c\u4f1a\u5bfc\u81f4\u6240\u5206\u914d\u7684\u7a7a\u95f4\u4e00\u76f4\u5360\u7740\u4e0d\u653e\uff0c\u5bfc\u81f4\u5185\u5b58\u6cc4\u9732\u3002 \u5168\u5c40\u5c40\uff1a\u7528\u6765\u5b58\u653e\u5168\u5c40\u53d8\u91cf\u548c\u9759\u6001\u53d8\u91cf\u3002\u5b58\u5728\u4e8e\u7a0b\u5e8f\u7684\u6574\u4e2a\u8fd0\u884c\u671f\u95f4\uff0c\u662f\u7531\u7f16\u8bd1\u5668\u5206\u914d\u548c\u91ca\u653e\u7684\u3002 \u6587\u5b57\u5e38\u91cf\u533a\uff1a\u4f8b\u5982char *c = \u201c123456\u201d\uff1b\u5219\u201d123456\u201d\u4e3a\u6587\u5b57\u5e38\u91cf\uff0c\u5b58\u653e\u4e8e\u6587\u5b57\u5e38\u91cf\u533a\u3002\u4e5f\u7531\u7f16\u8bd1\u5668\u63a7\u5236\u5206\u914d\u548c\u91ca\u653e\u3002 \u7a0b\u5e8f\u4ee3\u7801\u533a\uff1a\u7528\u6765\u5b58\u653e\u7a0b\u5e8f\u7684\u4e8c\u8fdb\u5236\u4ee3\u7801\u3002 \u4f8b\u5b50(\u4e00) int a = 0; \/\/\u5168\u5c40\u533a void main() { int b; \/\/\u6808 char s[] = abc; \/\/s\u5728\u6808,abc\u5728\u6587\u5b57\u5e38\u91cf\u533a char *p1,*p2; \/\/\u6808 char *p3 = &#8220;123456&#8221;; \/\/123456\u5728\u5e38\u91cf\u533a\uff0cp3\u5728\u6808\u4e0a static int c =0;","og_url":"https:\/\/pjq.me\/?p=98","og_site_name":"Jianqing&#039;s Blog","article_published_time":"2008-09-10T10:37:39+00:00","article_modified_time":"2018-12-07T15:15:03+00:00","author":"pengjianqing","twitter_card":"summary_large_image","twitter_misc":{"Written by":"pengjianqing","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/pjq.me\/?p=98#article","isPartOf":{"@id":"https:\/\/pjq.me\/?p=98"},"author":{"name":"pengjianqing","@id":"https:\/\/pjq.me\/#\/schema\/person\/0eb1e72d1e69fbbd9b5c0bfd8e2aae60"},"headline":"[\u8f6c]C\u8bed\u8a00\u5185\u5b58\u5206\u914d\u95ee\u9898","datePublished":"2008-09-10T10:37:39+00:00","dateModified":"2018-12-07T15:15:03+00:00","mainEntityOfPage":{"@id":"https:\/\/pjq.me\/?p=98"},"wordCount":213,"commentCount":0,"publisher":{"@id":"https:\/\/pjq.me\/#\/schema\/person\/0eb1e72d1e69fbbd9b5c0bfd8e2aae60"},"articleSection":["Tech"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/pjq.me\/?p=98#respond"]}]},{"@type":"WebPage","@id":"https:\/\/pjq.me\/?p=98","url":"https:\/\/pjq.me\/?p=98","name":"[\u8f6c]C\u8bed\u8a00\u5185\u5b58\u5206\u914d\u95ee\u9898 - Jianqing&#039;s Blog","isPartOf":{"@id":"https:\/\/pjq.me\/#website"},"datePublished":"2008-09-10T10:37:39+00:00","dateModified":"2018-12-07T15:15:03+00:00","breadcrumb":{"@id":"https:\/\/pjq.me\/?p=98#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/pjq.me\/?p=98"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/pjq.me\/?p=98#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/pjq.me\/"},{"@type":"ListItem","position":2,"name":"[\u8f6c]C\u8bed\u8a00\u5185\u5b58\u5206\u914d\u95ee\u9898"}]},{"@type":"WebSite","@id":"https:\/\/pjq.me\/#website","url":"https:\/\/pjq.me\/","name":"Jianqing&#039;s Blog","description":"Thoughts and Future","publisher":{"@id":"https:\/\/pjq.me\/#\/schema\/person\/0eb1e72d1e69fbbd9b5c0bfd8e2aae60"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/pjq.me\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/pjq.me\/#\/schema\/person\/0eb1e72d1e69fbbd9b5c0bfd8e2aae60","name":"pengjianqing","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/pjq.me\/#\/schema\/person\/image\/","url":"https:\/\/pjq.me\/wp-content\/uploads\/2021\/12\/Screen-Shot-2021-12-02-at-6.10.58-PM.png","contentUrl":"https:\/\/pjq.me\/wp-content\/uploads\/2021\/12\/Screen-Shot-2021-12-02-at-6.10.58-PM.png","width":460,"height":752,"caption":"pengjianqing"},"logo":{"@id":"https:\/\/pjq.me\/#\/schema\/person\/image\/"},"url":"https:\/\/pjq.me\/?author=1"}]}},"views":1861,"_links":{"self":[{"href":"https:\/\/pjq.me\/index.php?rest_route=\/wp\/v2\/posts\/98","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pjq.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pjq.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pjq.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pjq.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=98"}],"version-history":[{"count":0,"href":"https:\/\/pjq.me\/index.php?rest_route=\/wp\/v2\/posts\/98\/revisions"}],"wp:attachment":[{"href":"https:\/\/pjq.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pjq.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pjq.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}