{"id":93969,"date":"2020-04-20T23:09:17","date_gmt":"2020-04-20T15:09:17","guid":{"rendered":"http:\/\/4563.org\/?p=93969"},"modified":"2020-04-20T23:09:17","modified_gmt":"2020-04-20T15:09:17","slug":"go-%e8%af%ad%e8%a8%80%e9%87%8c%e9%9d%a2%e7%9a%84%e6%8c%87%e9%92%88%ef%bc%9a-array-int-%e5%92%8c-array-int-%e7%9a%84%e5%8c%ba%e5%88%ab%e6%98%af%e5%95%a5","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=93969","title":{"rendered":"Go \u8bed\u8a00\u91cc\u9762\u7684\u6307\u9488\uff1a array *[ ]int \u548c array[ ]*int \u7684\u533a\u522b\u662f\u5565"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Go \u8bed\u8a00\u91cc\u9762\u7684\u6307\u9488\uff1a array *[ ]int \u548c array[ ]*int \u7684\u533a\u522b\u662f\u5565               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : tqz <\/span>  <span><i><\/i> 26<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<h4>\u6211\u5b9a\u4e49\u6570\u7ec4\u6307\u9488\u7684\u65f6\u5019\u7528\u7684\u662f\uff1avar array [3]*int<\/h4>\n<h4>\u6211\u5728\u51fd\u6570\u91cc\u9762\u4f20\u9012\u4e00\u4e2a\u6570\u7ec4\u7684\u5730\u5740\u7684\u65f6\u5019\u8981\u7528\u4e00\u4e2a\u6570\u7ec4\u6307\u9488\u6765\u63a5\u6536\u5b83\u7684\u5730\u5740\uff0c\u6211\u5199\u7684\u662f\uff1aarray *[]int<\/h4>\n<h2>\u8fd9\u4e24\u79cd\u5199\u6cd5\u7684\u533a\u522b\u662f\u5565\u554a<\/h2>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>9<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1182577\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Fitz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6570\u7ec4\u5143\u7d20\u6307\u9488\u548c\u6570\u7ec4\u672c\u8eab\u6307\u9488                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1182578\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : justin2018 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6570\u7ec4\u6307\u9488\u662f\u6307\u5411\u6570\u7ec4\u5730\u5740\u7684\u6307\u9488<\/p>\n<p>\u6307\u9488\u6570\u7ec4\u662f\u6570\u7ec4\u91cc\u9762\u5168\u90fd\u662f\u6307\u9488\u7c7b\u578b<\/p>\n<p>https:\/\/learnku.com\/docs\/qianxi-golang\/section-4-pointer-array-pointer-and-pointer-array\/6347 <\/p>\n<p>\u6211\u5f53\u521d\u662f\u770b\u8fd9\u4e2a\u7406\u89e3\u7684                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1182579\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : tqz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             ## \u6211\u7684 demo<\/p>\n<p>&#8220;`go<br \/>package main<\/p>\n<p>import &#8220;fmt&#8221;<\/p>\n<p>func main() {<\/p>\n<p> array := []int{1, 2, 3, 4, 5}<br \/> fmt.Println(&#8220;array[0]=&#8221;, array[0])<br \/> changeArray(&amp;array)<br \/> fmt.Println(&#8220;array[0]=&#8221;, array[0])<\/p>\n<p>}<\/p>\n<p>\/\/ \u51fd\u6570\u7684\u6307\u9488\u53c2\u6570<br \/>func changeArray(array *[]int) {<br \/> (*array)[0] = 123456789<br \/>}<\/p>\n<p>\/\/ \u6570\u7ec4\u6307\u9488\uff1a\u6307\u7684\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u4e2a\u6307\u9488\u6307\u5411\u4e86\u4e00\u4e2a\u6570\u7ec4<br \/>\/\/ \u6307\u9488\u6570\u7ec4\uff1a\u6307\u7684\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c\u8fd9\u4e2a\u6570\u7ec4\u91cc\u9762\u88c5\u6ee1\u4e86\u6307\u9488\u3002<br \/>func arrayPtr() {<\/p>\n<p> a := []int{1, 2, 3}<br \/> len := len(a)<\/p>\n<p> var ptr [3]*int<\/p>\n<p> for i := 0; i &lt; len; i++ {<br \/> ptr[i] = &amp;a[i]<br \/> }<\/p>\n<p> for i := 0; i &lt; len; i++ {<br \/> fmt.Printf(&#8220;%pn&#8221;, ptr[i])<br \/> }<br \/>}<br \/>&#8220;`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1182580\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : mcfog <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u611f\u89c9\u8fd9\u662f\u5927\u6982\u7387\u6ca1\u641e\u660e\u767d golang \u8bed\u5883\u4e0b\u7684 slice array pointer \u8fd9\u51e0\u4e2a\u4e1c\u897f\u624d\u4f1a\u5199\u51fa\u8fd9\u6837\u7684\u7c7b\u578b\u95ee\u51fa\u8fd9\u6837\u7684\u95ee\u9898\u6765\uff0c\u5efa\u8bae\u5148\u770b\u4efb\u610f\u6559\u7a0b\u7684\u76f8\u5173\u5185\u5bb9                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1182581\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : silvernoo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             slice \u7684\u6307\u9488\u6ca1\u6709\u610f\u4e49                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1182582\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : CEBBCAT <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6570\u7ec4\u540d\u662f\u4e00\u4e2a\u6570\u636e\u7ed3\u6784\uff0c\u5305\u542b\u957f\u5ea6\uff0c\u5bb9\u91cf\uff0c\u548c\u4e00\u4e2a\u6307\u5411\u5185\u5bb9\u7684\u6307\u9488\u3002\u90a3\u4e48*\uff3b\uff3d int \u662f\u6307\u5411\u4e00\u4e2a\u6570\u7ec4\u540d\u7684\u6307\u9488\uff0c\u800c\uff3b\uff3d*int \u662f\u5143\u7d20\u4e3a int \u6307\u9488\u7684\u6570\u7ec4\u3002<\/p>\n<p>\u5efa\u8bae\u7528\u5c0f\u4f8b\u5b50\u6765\u68c0\u67e5\u4e00\u4e0b\uff0c\u6211\u4e5f\u662f\u521d\u5b66\uff08\u53e6\u5916\u6c42\u4e0a\u6d77 Go \u53ef\u8f6c\u6b63\u5b9e\u4e60\uff09                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1182583\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Allianzcortex <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6570\u7ec4\u6307\u9488\u548c\u6307\u9488\u6570\u7ec4\uff0c\u60f3\u8d77\u4e86\u671f\u672b\u8003\u8bd5\u7684 C++ \u9898&#8230;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1182584\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xuanbg <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             array *[ ]int \u662f\u6570\u7ec4\u6307\u9488\uff0c\u6307\u5411\u4e00\u4e2a\u6570\u7ec4\u7684\u6307\u9488\uff0c\u5b83\u662f\u4e2a\u6307\u9488\u3002array[ ]*int \u662f\u6307\u9488\u6570\u7ec4\uff0c\u662f\u5b58\u653e\u82e5\u5e72\u6307\u9488\u7684\u6570\u7ec4\uff0c\u5b83\u662f\u4e2a\u6570\u7ec4\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1182585\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jack1998 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @xuanbg []int \u662f\u5207\u7247\u5427                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Go \u8bed\u8a00\u91cc\u9762\u7684\u6307\u9488\uff1a array&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\/93969"}],"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=93969"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/93969\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=93969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=93969"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=93969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}