{"id":160317,"date":"2020-09-26T06:10:42","date_gmt":"2020-09-25T22:10:42","guid":{"rendered":"http:\/\/4563.org\/?p=160317"},"modified":"2020-09-26T06:10:42","modified_gmt":"2020-09-25T22:10:42","slug":"%e5%87%bd%e6%95%b0%e5%a4%96%e6%9c%89%e5%88%86%e9%85%8d%e5%86%85%e5%ad%98%e7%9a%84-char-outside%ef%bc%8c%e5%87%bd%e6%95%b0%e5%86%85%e6%9c%89%e5%88%86%e9%85%8d%e5%86%85%e5%ad%98%e7%9a%84-char-inside","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=160317","title":{"rendered":"\u51fd\u6570\u5916\u6709\u5206\u914d\u5185\u5b58\u7684 char *outside\uff0c\u51fd\u6570\u5185\u6709\u5206\u914d\u5185\u5b58\u7684 char *inside\uff0c\u5982\u679c\u5148\u5c06 outside \u6240\u6307\u7684\u5185\u5b58\u91ca\u653e\u6389\uff0c\u7136\u540e\u5c06 inside \u6307\u9488\u8d4b\u503c\u7ed9 outside\uff0c\u53ef\u884c\u5417\uff1f\u51fd\u6570\u7ed3\u675f\u540e\u4f1a\u88ab\u91ca\u653e\u5417\uff1f\u6709\u6ca1\u6709\u98ce\u9669\u3002"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u51fd\u6570\u5916\u6709\u5206\u914d\u5185\u5b58\u7684 char *outside\uff0c\u51fd\u6570\u5185\u6709\u5206\u914d\u5185\u5b58\u7684 char *inside\uff0c\u5982\u679c\u5148\u5c06 outside \u6240\u6307\u7684\u5185\u5b58\u91ca\u653e\u6389\uff0c\u7136\u540e\u5c06 inside \u6307\u9488\u8d4b\u503c\u7ed9 outside\uff0c\u53ef\u884c\u5417\uff1f\u51fd\u6570\u7ed3\u675f\u540e\u4f1a\u88ab\u91ca\u653e\u5417\uff1f\u6709\u6ca1\u6709\u98ce\u9669\u3002               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ReputationZh <\/span>  <span><i><\/i> 1<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt;  char *ptrToptr(char *outside) {     char *inside = NULL;      inside = (char *)malloc(200 * sizeof(char));     strcpy(inside, \"inside\");     free(outside);      return inside; }  int main() {     char *outside = NULL;     outside = (char *)malloc(100 * sizeof(char));     strcpy(outside, \"outside\");     outside = ptrToptr(outside);      printf(\"%sn\", outside);      free(outside); } <\/code><\/pre>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>15<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3464209\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jmc891205 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u884c\uff0c\u51fd\u6570\u7ed3\u675f\u540e\u4e0d\u4f1a\u88ab\u91ca\u653e<br \/>\u98ce\u9669\u5c31\u662f\u624b\u52a8\u7ba1\u7406\u5185\u5b58\u5bfc\u81f4\u7684\u5404\u79cd bug                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3464210\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Yut <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b\u8d77\u6765\u610f\u601d\u53ea\u662f\u91cd\u590d\u4f7f\u7528 outside \u8fd9\u4e2a pointer \uff1f\u4e00\u6b21\u662f\u672c\u8eab\u81ea\u5df1\u7684\u4e00\u6b21\u662f inside \u7684\uff1f\u53ef\u4ee5\u662f\u53ef\u4ee5\uff0c\u4f46\u662f\u4e3a\u5565\u4e00\u5b9a\u8981\u7528 outside \u90a3\u4e2a pointer \u3002\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3464211\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhangmenglong <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f1a\u88ab\u91ca\u653e\u6389\u5427                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3464212\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wscanf <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u884c\u554a\u3002 \u4e0d\u5982\u76f4\u63a5\u8bf4\u4f60\u7684\u573a\u666f\uff0c\u770b\u770b\u6709\u4ec0\u4e48\u98ce\u9669                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3464213\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zmxnv123 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u8fd9\u90fd\u662f\u5806\u4e0a\u5185\u5b58\uff0c\u4e0d\u5206\u51fd\u6570\u5185\u5916\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3464214\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : mybyons <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u4e0d\u60f3\u81ea\u5df1\u88ab\u5176\u4ed6\u4eba\u6253\u6b8b \u8fd8\u662f\u4e0d\u8981\u8fd9\u4e48\u5e72                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3464215\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rigortek <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u884c<\/p>\n<p>main \u51fd\u6570\u7ed3\u675f\u65f6\uff0cptrToptr \u5206\u914d\u7684\u5185\u5b58\u4e5f\u88ab\u91ca\u653e\u6389\u4e86\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u6839\u636e\u51fd\u6570\u529f\u80fd\u5355\u4e00\u539f\u5219\uff0c\u91ca\u653e outptr \u7684\u6d3b\u5e94\u8be5\u5728 main \u4e2d\u8fdb\u884c\u3002<\/p>\n<p>\u56e0\u4e3a\u5185\u5b58\u662f\u5b83\u5206\u914d\u51fa\u6765\u7684\uff0c\u6839\u636e\u5185\u5b58\u7ba1\u7406\u4e00\u4e2a\u4e00\u822c\u6027\u539f\u5219\uff1a\u8c01\u5206\u914d\u8c01\u8d1f\u8d23\u91ca\u653e\u3002<\/p>\n<p>\u5f53\u7136\u4e5f\u6709\u4f8b\u5916\uff0c\u5982\u679c\u4f60\u662f api \u63d0\u4f9b\u8005\uff0c\u6709\u65f6\u751f\u547d\u5468\u671f\u4f60\u65e0\u6cd5\u638c\u63a7\uff0c\u6b64\u65f6\u7531\u8c03\u7528\u8005\u8d1f\u8d23\u91ca\u653e\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3464216\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ahhui <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u662f\u4f5c\u6b7b\u884c\u4e3a\uff0c\u522b\u8fd9\u6837\u73a9\uff0c\u67e5\u8d77 bug \u6765\u8981\u4eba\u547d\u3002\u4f60\u65e0\u6cd5\u786e\u5b9a\u7ed9\u4f60\u4f20 outside \u6307\u9488\u7684\u5916\u90e8\u662f\u4ec0\u4e48\u5185\u5b58\u7ba1\u7406\u5668\u5728\u7ba1\u7406\u5185\u5b58\uff0c\u5b83\u5206\u914d\u7684\u957f\u5ea6\u4e5f\u4e0d\u4e00\u5b9a\u662f\u544a\u8bc9\u4f60\u7684\u957f\u5ea6\uff08\u6bd4\u5982\u5728\u5206\u914d\u7684\u5185\u5b58\u4e2d\u4e2d\u6bb5\u6709\u4e2a NULL char\uff0c\u8fd9\u662f\u5f88\u5e38\u89c1\u7684\uff09\uff0c\u7136\u540e\u4f60\u53bb\u91ca\u653e\u6216\u8005\u91cd\u7528\u5916\u90e8\u6307\u9488\uff0c\u4f1a\u5e26\u6765\u8f7b\u5219\u5185\u5b58\u9519\u8bef\uff0c\u91cd\u5219\u88ab\u653b\u51fb\u8005\u5229\u7528\u6210\u4e3a\u53ef\u4ee5\u8fdc\u7a0b\u6ea2\u51fa\u6267\u884c\u4ee3\u7801\u7684\u6f0f\u6d1e\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3464217\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jones2000 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e3a\u4ec0\u4e48\u4e0d\u76f4\u63a5\u7528\u667a\u80fd\u6307\u9488\u5462\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3464218\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : VZXXBACQ <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @jones2000 \u8fd9\u662f C \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3464219\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Chenamy2017 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u884c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3464220\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lakehylia <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8c01\u5206\u914d\u7684\u5185\u5b58\uff0c\u8c01\u7ba1\u7406\u3002\u5047\u5982\u4f60\u6709\u4e2a api \u63d0\u4f9b\u5206\u914d\u7684\u5185\u5b58\u6307\u9488\uff0c\u6700\u597d\u540c\u65f6\u63d0\u4f9b\u4e00\u4e2a\u91ca\u653e\u5185\u5b58\u6307\u9488\u7684 api \u3002\u4e0d\u662f\u6240\u6709\u7684\u5185\u5b58\u6307\u9488\u80fd\u76f4\u63a5\u7528\u7cfb\u7edf\u9ed8\u8ba4\u7684 free \u7684\uff0c\u9b3c\u77e5\u9053\u4f60\u7684\u662f\u4ec0\u4e48\u5185\u5b58\u7ba1\u7406\u673a\u5236\u3002\u4f60\u8fd9\u4e48\u73a9\uff0c\u4f1a\u88ab\u4f60\u7684\u7ec4\u957f\u9a82\u7684\u3002\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3464221\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lxilu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8981\u786e\u5b9a\u80fd\u7528 free                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3464222\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jimmyismagic <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e00\u822c\u7528 char**\u4f5c\u4e3a\u53c2\u6570\uff0c\u4f20\u5165 outside \u6307\u9488\u5f15\u7528\uff0c\u7136\u540e\u5728\u91cc\u9762\u76f4\u63a5\u5206\u914d\u5185\u5b58\uff0c\u8fd9\u6837\u51fd\u6570\u91cc\u9762\u4e5f\u4e0d\u7528\u5f15\u7528 outside \u7684\u53d8\u91cf\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3464223\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yunshansimon <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u8fd9\u4e48\u5e72\uff0c\u4f46\u901a\u5e38\u6ca1\u6709\u8fd9\u4e48\u7528\u7684\u3002\u4e0d\u80fd\u628a\u7533\u8bf7\u548c\u91ca\u653e\u653e\u5230\u4e0d\u540c\u7684\u51fd\u6570\u91cc\u9762\u3002\u4f60\u65e2\u7136\u53eb out_side \u5c31\u8981\u7528 char**\u6700\u4e3a\u51fd\u6570\u53c2\u6570\uff0c\u4f20&amp;out_side \u8fdb\u53bb\u3002\u53e6\u5916\uff0c\u8981\u5728\u51fd\u6570\u5f00\u59cb\u68c0\u67e5 out_side \u5fc5\u987b\u662f NULL \uff08\u4e5f\u53ef\u4ee5\u4e0d\u68c0\u67e5\uff0c\u9ed8\u8ba4 NULL \uff09\u3002\u5426\u5219\u4f60\u4f1a\u517b\u6210\u574f\u4e60\u60ef\uff0c\u6bcf\u6b21\u62ff\u5230\u6307\u9488\u90fd\u80e1\u601d\u4e71\u60f3\u3002\u4f60\u7684\u9886\u5bfc\u5982\u679c\u5728\u9879\u76ee\u4e2d\u770b\u5230\u8fd9\u79cd\u4ee3\u7801\uff0c\u7b2c\u4e00\u65f6\u95f4\u5c31\u60f3\u628a\u4f60\u6390\u6b7b\uff0c\u7136\u540e\u628a\u4f60\u8001\u5e08\u4e5f\u6390\u6b7b\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u51fd\u6570\u5916\u6709\u5206\u914d\u5185\u5b58\u7684 char *o&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/160317"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=160317"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/160317\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=160317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=160317"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=160317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}