{"id":383,"date":"2017-11-04T13:43:30","date_gmt":"2017-11-04T05:43:30","guid":{"rendered":"https:\/\/colliot.me\/?p=383"},"modified":"2017-11-23T23:45:51","modified_gmt":"2017-11-23T15:45:51","slug":"%e4%be%8b%e8%af%b4-c-%e8%af%ad%e8%a8%80%e7%b1%bb%e5%9e%8b%e5%a3%b0%e6%98%8e","status":"publish","type":"post","link":"https:\/\/colliot.org\/en\/2017\/11\/%e4%be%8b%e8%af%b4-c-%e8%af%ad%e8%a8%80%e7%b1%bb%e5%9e%8b%e5%a3%b0%e6%98%8e\/","title":{"rendered":"Demystifying the Type Declarations in C"},"content":{"rendered":"<p><\/p>\n<div>The type declarations in C, restricted by C&#8217;s long history, appears rather complicated in many situations. Let&#8217;s give it a thorough analysis today.<\/div>\n<div class=\"RichContent-inner\">\n<h1>Pointers and Arrays<\/h1>\n<h2>Nested Once<\/h2>\n<p>Even the very beginners wouldn&#8217;t find the following problems hard:<\/p>\n<p>Are you able to declare an array?<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int a[5]; \/\/ With 5 elements.<\/pre>\n<p>Are you able to declare a pointer?<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int *a;<\/pre>\n<h2>Nested Twice<\/h2>\n<p>Are you able to declare a nested pointer?<\/p>\n<p><!--more--><\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int **a;<\/pre>\n<p>\u4f60\u4f1a\u58f0\u660e\u4e8c\u7ef4\u6570\u7ec4\u5417\uff1f<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">\/\/ \u7b2c\u4e00\u7ef4\u957f 5\uff0c\u7b2c\u4e8c\u7ef4\u957f 7\r\nint a[5][7];<\/pre>\n<p>\u90a3\u4f60\u4f1a\u58f0\u660e\u6307\u9488\u7684\u6570\u7ec4\u5417\uff1f<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">\/\/ \u6570\u7ec4\u7684\u957f\u5ea6\u4e3a 7\r\nint *a[7];<\/pre>\n<p>\u4f60\u4f1a\u58f0\u660e\uff08\u6307\u5411\uff09\u6570\u7ec4\u7684\u6307\u9488\u5417\uff1f<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int (*a)[5];<\/pre>\n<p><b>\u601d\u8003\u9898 1<\/b>\uff1a\u4e8c\u7ef4\u6570\u7ec4\u3001\u6570\u7ec4\u7684\u6307\u9488\u3001\u6307\u9488\u7684\u6570\u7ec4\uff0c\u8fd9\u4e9b\u4e1c\u897f\u662f\u4e00\u6837\u7684\u5417\uff1f\u6709\u76f8\u540c\u7684\u5417\uff1f\u8fd8\u662f\u5404\u4e0d\u76f8\u540c\uff1f<\/p>\n<p>\u7b54\u6848\uff1a\u53ef\u53c2\u8003<a class=\"internal\" href=\"https:\/\/zhuanlan.zhihu.com\/p\/24799071\">\u300a\u8bf4\u51fa\u6765\u4f60\u4eec\u53ef\u80fd\u4e0d\u4fe1\uff0c\u4f46\u662f\u6570\u7ec4\u540d\u786e\u5b9e\u4e0d\u662f\u6307\u9488\u5e38\u91cf\u300b<\/a>\u3002\u4ee5\u540e\u6211\u4e5f\u53ef\u80fd\u4f1a\u5199\u3002<\/p>\n<p>\u4e00\u5b9a\u8981\u6ce8\u610f\uff0c\u7528\u6307\u9488\u7c7b\u578b\u4ee3\u66ff\u6570\u7ec4\u662f\u9519\u8bef\u7684\u505a\u6cd5\u2014\u2014\u5bf9\u4e8e\u591a\u91cd\u6570\u7ec4\u548c\u591a\u91cd\u6307\u9488\uff0c\u5b83\u4eec\u4e0b\u6807\u7684\u8bed\u4e49\u662f\u4e0d\u4e00\u6837\u7684\u3002\u65e0\u8bba\u51e0\u7ef4\u6570\u7ec4\uff0c\u5b83\u4eec\u7684\u5185\u5b58\u5e03\u5c40\u603b\u662f\u7ebf\u6027\u7684\uff0c\u6307\u9488\u5374\u4e0d\u7136\uff0c\u6709\u591a\u5c11\u91cd\u5c31\u4f1a\u771f\u7684\u505a\u591a\u5c11\u6b21\u8df3\u8f6c\u3002<\/p>\n<h2>\u4e09\u91cd\u58f0\u660e<\/h2>\n<p>\u4f60\u4f1a\u58f0\u660e\u3010\u6570\u7ec4\u7684\u6307\u9488\u3011\u7684\u6570\u7ec4\u5417\uff1f<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int (*a[9])[5];<\/pre>\n<p>\u4f60\u4f1a\u58f0\u660e\u6307\u5411\u3010\u6307\u9488\u7684\u6570\u7ec4\u3011\u7684\u6307\u9488\u5417\uff1f<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int *(*a)[5];<\/pre>\n<p>\u8ba9\u6211\u4eec\u6765\u8bd5\u7740\u9a8c\u8bc1\u4e00\u4e0b\u3002\u600e\u4e48\u9a8c\u8bc1\u5462\uff1f\u53ea\u8981\u6309\u7167\u6982\u5ff5\uff08\u6bd4\u5982\u6570\u7ec4\u7684\u6307\u9488\u7684\u6570\u7ec4\uff09\uff0c\u4e00\u6b65\u4e00\u6b65\u6784\u9020\u5e76\u4e14\u8d4b\u503c\uff0c\u6700\u540e\u80fd\u7f16\u8bd1\u901a\u8fc7\uff0c\u6ca1\u6709\u8b66\u544a\uff0c\u5c31\u8bf4\u660e\u6211\u4eec\u4ece\u6982\u5ff5\u5230\u4ee3\u7801\u7684\u7ffb\u8bd1\u662f\u5bf9\u7684\u3002<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int a1 = 1;\r\nint a2 = 2;\r\nint a3 = 3;\r\nint a4 = 4;\r\nint a5 = 5;\r\n\r\nint aa1[5] = {1, 2, 3, 4, 5};\r\nint aa2[5] = {1, 2, 3, 4, 5};\r\nint aa3[5] = {1, 2, 3, 4, 5};\r\n\/\/ \u4e8c\u7ef4\r\nint *aa[5] = {&amp;a1, &amp;a2, &amp;a3, &amp;a4, &amp;a5};\r\nint (*aa1d)[5] = &amp;aa1;\r\n\/\/ \u4e09\u7ef4\r\nint *(*a)[5] = &amp;aa;\r\nint (*b[3])[5] = {&amp;aa1, &amp;aa2, &amp;aa3};<\/pre>\n<p>\u770b\u660e\u767d\u4e86\u5417\uff1f\u8fd9\u80cc\u540e\u7684\u539f\u7406\u662f\u4ec0\u4e48\u5462\uff1f<\/p>\n<p>\u5b9e\u9645\u4e0a\u8fd9\u4f53\u73b0\u4e86\u67d0\u79cd\u9012\u5f52\u6027\u2014\u2014<\/p>\n<blockquote><p>\u5982\u679c\u4e00\u4e2a\u58f0\u660e\u5f62\u5982 T *D\uff08\u5047\u8bbe\u53d8\u91cf ident \u5728 D \u4e2d\uff09\uff0c\u800c T D \u58f0\u660e\u4e86\u4e00\u4e2a\u3010\u5b9a\u8bed + T\u3011\u7c7b\u578b\u7684\u53d8\u91cf\u7684\u8bdd\uff0c\u90a3\u4e48 T *D \u5c31\u58f0\u660e\u4e86\u6307\u5411\u7c7b\u578b T \u7684\u3010\u5b9a\u8bed + \u6307\u9488\u3011 ident\u3002<br \/>\n\u5982\u679c\u4e00\u4e2a\u58f0\u660e\u5f62\u5982 T D[n]\uff08\u5047\u8bbe\u53d8\u91cf ident \u5728 D \u4e2d\uff09\uff0c\u800c T D \u58f0\u660e\u4e86\u4e00\u4e2a\u3010\u5b9a\u8bed + T\u3011\u7c7b\u578b\u7684\u53d8\u91cf\u7684\u8bdd\uff0c\u90a3\u4e48 T D[n] \u5c31\u58f0\u660e\u4e86\u957f\u5ea6\u4e3a n \u7684\u3001\u7c7b\u578b\u4e3a T \u7684\u3010\u5b9a\u8bed + \u6570\u7ec4\u3011ident\u3002<\/p><\/blockquote>\n<p>\u6709\u4e9b\u6666\u6da9\uff0c\u662f\u4e0d\u662f\uff1f\u8ba9\u6211\u4eec\u518d\u62ff\u4f8b\u5b50\u56de\u987e\u4e00\u4e0b\u3002\u6bd4\u5982 int (*b[3])[5] \u4e2d\uff1a<\/p>\n<ul>\n<li>D \u5c31\u662f (*b[3])\uff0cT D \u5219\u662f int (*b[3])\uff0c\u8bf4\u660e a \u662f\u4e00\u4e2a\u957f\u5ea6\u4e3a 5 \u7684\uff0c\u5982\u679c\u8bf4 int (*b[3]) \u58f0\u660e\u4e86\u4e00\u4e2a\u3010\u4ec0\u4e48\u3011of int \u7684\u8bdd\uff0cint (*b[3])[5] \u5c31\u58f0\u660e\u4e86\u4e00\u4e2a\u3010\u4ec0\u4e48\u3011\u7684\u3001\u957f\u5ea6\u4e3a 5 \u6570\u7ec4 of int<\/li>\n<li>\u518d\u62c6\u89e3\u5f97 int b[3]\uff0c\u662f\u4e00\u4e2a\u3010\u957f\u5ea6\u4e3a 3 \u6570\u7ec4 of\u3011 int\uff08\u6ce8\u610f T \u662f int\uff09\uff0c\u8bf4\u660e int (*b[3]) \u58f0\u660e\u7684\u662f\u3010\u957f\u5ea6\u4e3a 3 \u6570\u7ec4 of\u3011\u3010\u6307\u5411 int \u7684\u6307\u9488\u3011\uff0c\u4ece\u800c\u4e0a\u6587\u7684\u3010\u4ec0\u4e48\u3011\uff0c\u5c31\u662f\u3010\u957f\u5ea6\u4e3a 3 \u6570\u7ec4 of \u6307\u5411 &lt;\u5b83&gt; \u7684\u6307\u9488\u3011\uff0c\u8fd9\u4e2a &lt;\u5b83&gt; \u5c31\u662f\u8fd9\u4e2a\u5b9a\u8bed\u4fee\u9970\u7684\u5bf9\u8c61\u8981\u586b\u5165\u7684\u5730\u65b9\u3002<\/li>\n<li>\u8ba9\u6211\u4eec\u628a\u7b2c\u4e00\u6b65\u7684\u3010\u957f\u5ea6\u4e3a 5 \u6570\u7ec4 of int\u3011\u586b\u8fdb\u8fd9\u4e2a &lt;\u5b83&gt;\uff0c\u5c31\u4f1a\u5f97\u5230\u3010\u957f\u5ea6\u4e3a 3 \u6570\u7ec4 of \u6307\u5411 \u3010\u957f\u5ea6\u4e3a 5 \u6570\u7ec4 of int\u3011 \u7684\u6307\u9488\u3011\u3002<\/li>\n<li>\u7528\u4eba\u8bdd\u8bf4\uff0c\u5c31\u662f\u4e00\u4e2a\u957f\u5ea6\u4e3a 3 \u7684\u6570\u7ec4\uff0c\u5b83\u5305\u542b\u7684\u662f\u4e00\u4e9b\u6307\u9488\uff0c\u8fd9\u4e9b\u6307\u9488\u6307\u5411\u957f\u5ea6\u4e3a 5 \u7684 int \u6570\u7ec4\u3002\u8fd9\u548c\u6211\u4eec\u7684\u4ee3\u7801 int (*b[3])[5] = {&amp;aa1, &amp;aa2, &amp;aa3} \u4e5f\u662f\u4e00\u81f4\u7684\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u4fbf\u662f\u6807\u51c6\u4e2d\u5bf9\u7c7b\u578b\u7684\u300c\u9012\u5f52\u300d\u5b9a\u4e49\u3002\u8fd9\u770b\u8d77\u6765\u5bf9\u4eba\u7c7b\u592a\u4e0d\u53cb\u597d\u4e86\uff0c\u4f46\u662f\u6211\u4eec\u4e5f\u66f4\u4eba\u6027\u5316\u7684\u7b49\u4ef7\u89e3\u8bfb\u2014\u2014\u300c\u66ff\u6362\u300d\u3002\u6bd4\u5982\u8fd8\u662f\u5bf9\u8fd9\u4e2a int (*b[3])[5]\uff1a<\/p>\n<ul>\n<li>\u6ce8\u610f <b>[3] \u7684\u4f18\u5148\u7ea7\u6bd4 * \u8981\u9ad8<\/b>\u3002\u6211\u4eec\u5148\u628a b[3] \u66ff\u6362\u6210 c\uff0c\u90a3\u4e48 b \u7684\u7c7b\u578b\u5c31\u4f1a\u662f\u542b\u6709 3 \u4e2a\u5143\u7d20\u7684\u3001c \u7684\u7c7b\u578b\u7684\u6570\u7ec4\u3002<\/li>\n<li>int (*c)[5]\uff0c\u7531\u4e8e\u62ec\u53f7\u7684\u5b58\u5728\uff0c\u6211\u4eec\u8fd9\u65f6\u5019\u4f1a\u66ff\u6362 *c\uff0c\u800c\u4e0d\u662f c[5]\u3002\u5047\u8bbe\u66ff\u6362\u4e3a d\uff0c\u4ece\u800c int d[5]\uff0c\u90a3\u4e48 c \u662f\u4e00\u4e2a\u6307\u5411 d \u7684\u7c7b\u578b\uff08\u7684\u53d8\u91cf\uff09\u7684\u6307\u9488\u3002<\/li>\n<li>d \u7c7b\u578b\u5c31\u5f88\u7b80\u5355\u4e86\uff0c\u662f\u4e00\u4e2a 5 \u4e2a\u5143\u7d20\u7684 int \u6570\u7ec4\u3002<\/li>\n<li>\u90a3\u4e48\u6211\u4eec\u5c06\u4ee5\u4e0a\u4e32\u8054\u8d77\u6765\u2014\u2014 b \u662f\u3010\u542b\u6709 3 \u4e2a\u5143\u7d20\u7684\u3011\u3010\u5143\u7d20\u662f\uff3b\u6307\u5411\u3014\u6709 5 \u4e2a\u5143\u7d20\u7684 int \u6570\u7ec4\u3015\u7684\u6307\u9488\uff3d\u3011\u7684\u6570\u7ec4\u3002\u770b\uff0c\u8fd8\u662f\u4e00\u6837\u7684\u5427\u3002<\/li>\n<\/ul>\n<p>\u5b9e\u9645\u4e0a\u8fd9\u5c31\u662f<b>\u81ea\u5e95\u5411\u4e0a<\/b>\u800c\u4e0d\u662f<b>\u81ea\u9876\u5411\u4e0b<\/b>\u89e3\u8bfb\u90a3\u6837\u7684\u9012\u5f52\u89e3\u6790\u89c4\u5219\u7f62\u4e86\u3002<\/p>\n<p>\u800c\u5982\u679c\u6211\u4eec\u4e0d\u614e\u591a\u52a0\u4e86\u4e00\u4e2a\u62ec\u53f7\uff0c\u6bd4\u5982 int (*a[9])[5] \u53d8\u6210\u4e86 int ((*a)[9])[5]\uff0c\u90a3\u4e48\u7ed3\u679c\u5c31\u4f1a\u53d8\u5473\u4e86\u3002\u62c6\u89e3\u5230 int ((*a)[9]) \u7684\u65f6\u5019\uff0c\u4f1a\u4f18\u5148\u62c6\u89e3\u6210\u6570\u7ec4\uff0c\u4ece\u800c\u6700\u540e\u53d8\u6210\u4e86\u6307\u5411\u6570\u7ec4\u7684\u6570\u7ec4\uff08\u4e8c\u7ef4\u6570\u7ec4\uff09\u7684\u6307\u9488\u4e86\u3002<\/p>\n<p>\u6bd4\u5982 int *(*a)[5]\u2014\u2014<\/p>\n<ul>\n<li>\u6211\u4eec\u53ef\u4ee5\u628a (*a) \u66ff\u6362\u6210 b\uff0c\u8fd9\u6837 a \u4fbf\u662f\u6307\u5411 b \u88ab\u5b9a\u4e49\u7684\u7c7b\u578b\u7684\u6307\u9488\u3002<\/li>\n<li>\u800c int *b[5]\uff0c\u6211\u4eec\u53c8\u53ef\u4ee5\u628a b[5] \u66ff\u6362\u6210 c\uff08\u53ef\u4ee5\u770b\u51fa\uff0c\u8fd9\u6837\u7684\u7406\u89e3\u4e0b\uff0c\u300c\u4e0b\u6807\u300d\u8981\u6bd4\u300c\u89e3\u5f15\u7528\u300d\uff0c\u5c31\u662f\u5c0f\u661f\u661f\uff0c\u4f18\u5148\u7ea7\u66f4\u9ad8\uff09\uff0c\u90a3\u4e48 b \u4fbf\u662f\u5bb9\u7eb3 c \u7684\u7c7b\u578b\u7684\u3001\u957f\u5ea6\u4e3a 5 \u7684\u6570\u7ec4\u3002<\/li>\n<li>\u6700\u540e int *c\uff0c\u5219 c \u662f\u6307\u5411\u6574\u6570\u7684\u6307\u9488\u3002<\/li>\n<li>\u4ece\u800c\u539f\u672c\u58f0\u660e\u7684 a \u662f\u4e00\u4e2a\u6307\u5411\u957f\u5ea6\u4e3a 5 \u7684\u3001\u5143\u7d20\u662f\u6574\u6570\u6307\u9488\u7684\u6570\u7ec4\u7684\u6307\u9488\uff0c\u4e5f\u5c31\u662f\u6307\u9488\u7684\u6570\u7ec4\u7684\u6307\u9488\u3002<\/li>\n<\/ul>\n<p><b>\u601d\u8003\u9898 2<\/b>\uff1a\u4e3a\u4ec0\u4e48 int *a[7] \u548c int (*a)[5] \u4e00\u4e2a\u662f\u6307\u9488\u7684\u6570\u7ec4\uff0c\u4e00\u4e2a\u662f\u6570\u7ec4\u7684\u6307\u9488\uff1f\u62ec\u53f7\u662f\u600e\u4e48\u8d77\u4f5c\u7528\u7684\uff1f<\/p>\n<p>\u8fd9\u6837\u7684\u601d\u60f3\uff0c\u540c\u6837\u53ef\u4ee5\u5957\u7528\u5230\u51fd\u6570\u7c7b\u578b\u4e0a\uff08\u56e0\u4e3a\u51fd\u6570\u7c7b\u578b\u4e5f\u662f\u8fd9\u6837\u9012\u5f52\u5b9a\u4e49\u7684\uff09\u3002<\/p>\n<h2>\u51fd\u6570<\/h2>\n<p>\u4f60\u4f1a\u58f0\u660e\u4e00\u4e2a\u51fd\u6570\u5417\uff1f\u60f3\u5fc5\u5927\u5bb6\u90fd\u4f1a\u3002<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int func(int, int);<\/pre>\n<p>\u8fd9\u5c31\u58f0\u660e\u4e86\u4e00\u4e2a\u540d\u4e3a func\uff0c\u63a5\u6536\u4e24\u4e2a int \u578b\u53c2\u6570\u7684\u53d8\u91cf\uff0c\u53ef\u4ee5\u8fd9\u4e48\u7528\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int result = func(1, 2);<\/pre>\n<p>\u90a3\u4e48\u4f60\u4f1a\u58f0\u660e\u4e00\u4e2a\u51fd\u6570\u7c7b\u578b\u7684\u53d8\u91cf\u5417\uff1f<\/p>\n<p>\u55ef\u54fc\uff1f<\/p>\n<p>\u7b49\u4e00\u4e0b\uff1f\u53d8\u91cf\uff1f\u5176\u5b9e\u4f60\u5728\u4f60\u58f0\u660e\u51fd\u6570\u7684\u65f6\u5019\uff0c\u5c31\u5df2\u7ecf\u7b49\u4e8e\u5728\u58f0\u660e\u4e86\u4e00\u4e2a\u51fd\u6570\u7c7b\u578b\u7684\u53d8\u91cf\u4e86\u3002\u53ea\u4e0d\u8fc7\u51fd\u6570\u300c\u53d8\u91cf\u300d<b>\u4e0d\u652f\u6301<\/b>\u7528\u7b49\u53f7\u300c\u8d4b\u503c\u300d\u3002\u8981\u4fee\u6539\u5b83\u7684\u300c\u503c\u300d\uff0c\u5fc5\u987b\u901a\u8fc7\u82b1\u62ec\u53f7\u8bed\u6cd5\uff0c\u64b0\u5199\u300c\u51fd\u6570\u4f53\u300d\uff0c\u6bd4\u5982\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int func(int a, int b) {\r\n  return a + b;\r\n}<\/pre>\n<p>\u8fd9\u662f\u5927\u5bb6\u719f\u77e5\u7684\u5185\u5bb9\u3002\u8fd9\u6837\uff0c\u6211\u4eec\u8fde\u51fd\u6570\u7c7b\u578b\u300c\u53d8\u91cf\u300d\u7684\u58f0\u660e\u4e5f\u77e5\u6653\u4e86\u2014\u2014\u5b83\u5c31\u662f\u6211\u4eec\u719f\u4e60\u7684\u51fd\u6570\u58f0\u660e\u3002\u53ef\u662f\u65e2\u7136\u5b83\u4e0d\u53ef\u4ee5\u8d4b\u503c\uff0c\u4e5f\u53ea\u80fd\u5b9a\u4e49\u81f3\u591a\u4e00\u6b21\uff0c\u5b83\u5c31\u4e0d\u662f\u4e2a\u300c\u53d8\u300d\u91cf\u4e86\uff0c\u90a3\u4e48\u4f1a\u5199\u5b83\u7684\u7c7b\u578b\u53c8\u6709\u4ec0\u4e48\u7528\u5462\uff1f<\/p>\n<p>\u5176\u5b9e\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u62ff\u6765\u4f20\u53c2\u5440\uff01\u6bd4\u5982\u4e0a\u9762\u7684 func\uff0c\u5c31\u662f\u628a\u4e24\u4e2a\u53c2\u6570\u52a0\u8d77\u6765\u3002\u73b0\u5728\u6211\u4eec\u60f3\u5229\u7528\u8fd9\u4e2a\u51fd\u6570\uff0c\u6784\u9020\u4e00\u4e2a\u628a\u5355\u4e2a\u6574\u6570\u52a0 1 \u7684\u51fd\u6570\u3002\u6211\u4eec\u8be5\u600e\u4e48\u63a5\u6536\u8fd9\u4e2a\u51fd\u6570\u4f5c\u4e3a\u53d8\u91cf\u7684\uff1f\u8fd9\u65f6\u5019\u6211\u4eec\u5c31\u9700\u8981\u5b83\u7684\u7c7b\u578b\u4e86\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int apply_on_1(int func(int, int), int);\r\n\r\nint apply_on_1(int func(int, int), int b) {\r\n  return func(1, b);\r\n}<\/pre>\n<p>\u539f\u6765\u51fd\u6570\u7c7b\u578b\u4e5f\u53ef\u4ee5\u8fd9\u4e48\u7528\u554a\uff01<\/p>\n<h2>\u590d\u6742\u51fd\u6570<\/h2>\n<p>\u73b0\u5728\u95ee\u9898\u53c8\u6765\u4e86\uff0c\u4f60\u4f1a\u58f0\u660e\u8fd4\u56de\u4ee5\u4e0a\u5404\u79cd\u7c7b\u578b\u7684\u51fd\u6570\u5417\uff1f\u4f60\u4f1a\u628a\u8fd9\u4e9b\u7c7b\u578b\uff08\u5305\u62ec\u51fd\u6570\uff09\u968f\u610f\u7ec4\u5408\u8d77\u6765\u5417\uff1f\u6bd4\u5982\u4e00\u4e2a\u63a5\u6536\u300c\uff08\u6570\u7ec4\u7684\u6307\u9488\uff09\u7684\u6570\u7ec4\u300d\uff0c\u8fd4\u56de\u300c\u6570\u7ec4\u7684\u6307\u9488\u300d\u7684\u51fd\u6570\u3002\u4e00\u4e2a\u6700\u7b80\u5355\u7684\u5b9e\u73b0\u5c31\u662f\u8fd4\u56de\u8fd9\u4e2a\u300c\uff08\u6570\u7ec4\u7684\u6307\u9488\uff09\u7684\u6570\u7ec4\u300d\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\uff0c\u5b83\u5fc5\u7136\u662f\u4e00\u4e2a\u300c\u6570\u7ec4\u7684\u6307\u9488\u300d\u3002<\/p>\n<p>\u5185\u5bb9\u77e5\u9053\u4e86\uff0c\u53ef\u662f\u7c7b\u578b\u53c8\u8be5\u5982\u4f55\u5199\u5462\uff1f\u53c2\u6570\u7c7b\u578b\u662f\u597d\u5199\u7684\uff0c\u6211\u4eec\u53ea\u8981\u628a\u300c\uff08\u6570\u7ec4\u7684\u6307\u9488\uff09\u7684\u6570\u7ec4\u300d\u7c7b\u578b\u4f9d\u6837\u7167\u642c\u5230\u53c2\u6570\u5217\u8868\u91cc\u5c31\u884c\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">some_type return_first(int (*a[9])[5]);<\/pre>\n<p>\u95ee\u9898\u5c31\u5316\u5f52\u5230\u4e86 some_type \u600e\u4e48\u5199\u4e0a\u3002\u5b9e\u9645\u4e0a\uff0c\u6211\u4eec\u8fd8\u662f\u53ea\u8981\u7262\u8bb0\u300c\u9012\u5f52\u300d\u6216\u8005\u8bf4\u300c\u66ff\u6362\u300d\u539f\u5219\u3002\u6211\u4eec\u628a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">return_first(int (*a[9])[5])<\/pre>\n<p>\u8fd9\u4e2a\u6574\u4f53\u5f53\u4f5c\u4e00\u4e2a\u53d8\u91cf\uff0c\u5b83\u5982\u679c\u662f\u4e00\u4e2a\u300c\u6570\u7ec4\u7684\u6307\u9488\u300d\u3002\u5b83\u4f1a\u5904\u5728\u4ec0\u4e48\u4f4d\u7f6e\u5462\uff1f\u56de\u987e\u300c\u6570\u7ec4\u7684\u6307\u9488\u300d\u7684\u58f0\u660e\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int (*a)[5];<\/pre>\n<p>\u8fd9\u65f6\u5019\u6211\u4eec\u53ea\u8981\u628a return_first(int (*a[9])[5]) \u4f5c\u4e3a\u4e00\u4e2a\u6574\u4f53\uff0c\u66ff\u6362\u5230\u4e0a\u9762\u7684 a \u4e2d\u53bb\uff0c\u5c31\u6210\u529f\u4e86\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int (*return_first(int (*a[9])[5]))[5];<\/pre>\n<p>\u5f88\u7b80\u5355\u8212\u7545\u662f\u4e0d\u662f\uff1f<\/p>\n<p>\u5176\u5b9e\u4f5c\u4e3a\u5728\u51fd\u6570\u58f0\u660e\u4e2d\uff0c\u53c2\u6570\u540d\u662f\u53ef\u4ee5\u7701\u7565\u7684\uff0c\u5373\u4f7f\u5b83\u662f\u88ab\u300c\u5305\u88f9\u300d\u5728\u4e2d\u95f4\u7684\u3002\u8fd9\u5c31\u662f\u8bf4\uff0c\u4ee5\u4e0a\u5b9a\u4e49\u7b49\u4ef7\u4e8e<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int (*return_first(int(*[9])[5]))[5];<\/pre>\n<p>\u800c\u5982\u679c\u6211\u4eec\u6709\u4e00\u4e2a\u63a5\u6536\u4ee5\u4e0a\u7c7b\u578b\uff0c\u8fd4\u56de double \u7684\u51fd\u6570\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u628a return_first \u4e5f\u7701\u6389\uff0c\u6bd4\u5982<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">double complex_func(int(*(int(*[9])[5]))[5]);<\/pre>\n<p>\u8fd9\u6837\u592a\u5413\u4eba\u4e86\u3002<\/p>\n<h2>\u51fd\u6570\u6307\u9488<\/h2>\n<p>\u6709\u4eba\u4f1a\u95ee\uff0c\u4e3a\u4ec0\u4e48\u53ea\u8c08\u51fd\u6570\u6307\u9488\uff0c\u4e0d\u8c08\u51fd\u6570\u6570\u7ec4\u5462\uff1fC \u8bed\u8a00\u4e0d\u5141\u8bb8\u58f0\u660e\u51fd\u6570\u6570\u7ec4\u3002\u60f3\u60f3\u524d\u6587\uff0c\u51fd\u6570\u4e0d\u80fd\u8d4b\u503c\uff0c\u53ea\u80fd\u5b9a\u4e49\uff0c\u5982\u679c\u58f0\u660e\u4e86\u51fd\u6570\u6570\u7ec4\uff0c\u6211\u4eec\u6839\u672c\u5c31\u65e0\u6cd5\u64cd\u4f5c\u554a\u3002\u4f46\u662f\u51fd\u6570\u662f\u53ef\u4ee5\u53d6\u5730\u5740\u7684\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u5b9a\u4e49\u5e76\u5e7f\u6cdb\u4f7f\u7528\u51fd\u6570\u6307\u9488\u3002<\/p>\n<p>\u51fd\u6570\u6307\u9488\uff0c\u5176\u5b9e\u5f88\u7b80\u5355\u3002\u4f60\u5df2\u7ecf\u77e5\u9053\u58f0\u660e int \u7c7b\u578b\u7684\u6307\u9488\u662f\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int *p_int;<\/pre>\n<p>\u90a3\u4e48\u58f0\u660e int func(int, int) \u7c7b\u578b\u7684\u6307\u9488 p_func\uff0c\u5c31\u5e94\u8be5\u662f\u628a *p_func \u5f53\u4f5c\u662f func \u4e00\u6837\u5e26\u5165\u8fdb int func(int, int)\uff0c\u4e5f\u5c31\u662f\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int (*p_func)(int, int);<\/pre>\n<p>\u4e3a\u4ec0\u4e48\u8981\u52a0\u62ec\u53f7\uff1f\u8fd9\u662f\u56e0\u4e3a\u51fd\u6570\u53c2\u6570\u5217\u8868\u7684\u4f18\u5148\u7ea7\u76f8\u8f83\u6307\u9488\u58f0\u660e\u7684\u4f18\u5148\u7ea7\u4e3a\u9ad8\uff0c\u5982\u679c\u4e0d\u52a0\u62ec\u53f7\uff0cp_func \u5c31\u9996\u5148\u4f1a\u88ab\u8ba4\u4e3a\u662f\u4e00\u4e2a\u51fd\u6570\u3002\u6211\u4eec\u524d\u9762\u5df2\u7ecf\u63a2\u8ba8\u8fc7\u8fd9\u4e2a\u95ee\u9898\u4e86\u3002\u4e3a\u4ec0\u4e48\u662f\u628a\u6307\u9488\u5e26\u5165\u8fdb\u51fd\u6570\u58f0\u660e\uff0c\u4e0d\u662f\u53cd\u8fc7\u6765\uff0c\u628a\u51fd\u6570\u5e26\u5165\u8fdb\u6307\u9488\u58f0\u660e\uff0c\u4e5f\u5c31\u662f\u5047\u88c5 func(int, int) \u662f\u4e00\u4e2a int *\uff1f\u90a3\u5c31\u662f\u58f0\u660e\u4e00\u4e2a\u8fd4\u56de\u6574\u6570\u6307\u9488\u7684\u51fd\u6570\u4e86\uff0c\u800c\u4e0d\u662f\u4e00\u4e2a\u51fd\u6570\u7684\u6307\u9488\u3002<\/p>\n<h2>\u51fd\u6570\u548c\u51fd\u6570\u6307\u9488<\/h2>\n<p>\u51fd\u6570\u548c\u51fd\u6570\u6307\u9488\u6709\u4ec0\u4e48\u533a\u522b\uff1f\u6700\u663e\u8457\u7684\u533a\u522b\u5c31\u662f\u51fd\u6570\u6307\u9488\u4e5f\u662f\u6307\u9488\uff0c\u53ef\u4ee5\u8d4b\u503c\u3002\u6bd4\u5982\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int func2(int a, int b) {\r\n  return a * b;\r\n}\r\n\r\nint (*p_func)(int, int) = &amp;func2;\r\nint (*another_p_func)(int, int) = func2;<\/pre>\n<p>\u6709\u4eba\u4f1a\u95ee\uff0c\u7b2c\u4e8c\u4e2a\u662f\u4ec0\u4e48\uff1f\u4e3a\u4ec0\u4e48\u4e0d\u7528\u300c\u53d6\u5730\u5740\u300d\u5c31\u53ef\u4ee5\u628a\u4e00\u4e2a\u300c\u51fd\u6570\u300d\u8d4b\u7ed9\u300c\u51fd\u6570\u6307\u9488\u300d\uff1f\u8fd9\u6b63\u662f\u300c\u51fd\u6570\u300d\u7684\u79cd\u79cd\u7279\u6b8a\u6027\u4e4b\u4e00\u2014\u2014\u5bf9\u4e8e\u6240\u6709\u9664\u4e86\u300c\u53d6\u5730\u5740\u300d(&amp;) \u548c\u300c\u53d6\u5927\u5c0f\u300d(sizeof) \u4e4b\u5916\u7684\u64cd\u4f5c\uff08\u5b9e\u9645\u4e0a\u5e76\u4e0d\u5141\u8bb8 sizeof \u4f5c\u7528\u4e8e\u51fd\u6570\uff09\uff0c\u51fd\u6570\u603b\u662f\u4f1a\u9690\u5f0f\u5730\u8f6c\u6362\u4e3a\u6307\u5411\u5b83\u7684\u6307\u9488\u3002\u6240\u4ee5\u5f53\u4f60\u628a\u51fd\u6570\u8d4b\u7ed9\u4e00\u4e2a\u53d8\u91cf\uff0c\u5b9e\u9645\u4e0a\u628a\u5b83\u7684\u5730\u5740\u8d4b\u7ed9\u90a3\u4e2a\u53d8\u91cf\uff0c\u5f53\u4f60\u628a\u51fd\u6570\u7684\u5730\u5740\u8d4b\u7ed9\u4e00\u4e2a\u53d8\u91cf\uff0c\u4f60<b>\u8fd8\u662f<\/b>\u5728\u628a\u5b83\u7684\u5730\u5740\u8d4b\u7ed9\u90a3\u4e2a\u53d8\u91cf\u3002<\/p>\n<p>\u4ece\u6b64\uff0c\u6211\u4eec\u5c31\u77e5\u6653\u4e86\u300c\u6570\u7ec4\u300d\u3001\u300c\u6307\u9488\u300d\u548c\u300c\u53d8\u91cf\u300d\u4efb\u610f\u6df7\u5408\u7684\u7c7b\u578b\u58f0\u660e\u3002<\/p>\n<h2>\u4fee\u9970\u7b26<\/h2>\n<p>\u6240\u8c13\u4fee\u9970\u7b26\uff0c\u5c31\u662f cv-qualifiers\uff0c\u4e5f\u5c31\u662f const \u548c volatile\u3002volitile \u662f\u4e00\u4e2a\u5982\u679c\u4e0d\u9762\u5411\u786c\u4ef6\u7f16\u7a0b\u5c31\u4e0d\u592a\u63a5\u89e6\u5230\u7684\u4e1c\u897f\uff0c\u5b83\u8868\u793a\u53d8\u91cf\u53ef\u80fd\u88ab\u7a0b\u5e8f\u4e4b\u5916\u7684\u4e1c\u897f\u4fee\u6539\uff08\u4f60\u53ef\u4ee5\u4e0d\u7528\u7ba1\u5b83\uff09\u3002const \u5219\u662f\u8f83\u5e38\u89c1\u7684\u4fee\u9970\u7b26\u3002\u5b83\u8868\u793a\u6240\u6307\u5411\u7684\u5bf9\u8c61\u662f\u4e0d\u53ef\u4fee\u6539\u7684\u3002\u6bd4\u5982\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int const a = 0;\r\na = 1; \/\/ \u4f1a\u62a5\u9519\uff0c\u56e0\u4e3a a \u662f `const` \u7684\u3002\r\nconst int b = 0;\r\nb = 1; \/\/ \u540c\u6837\u4f1a\u62a5\u9519\uff0c\u56e0\u4e3a b \u662f `const` \u7684\u3002<\/pre>\n<p>\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0cconst \u53ef\u4ee5\u653e\u5728\u7c7b\u578b\u524d\u540e\uff0c\u5982 int const \u548c const int\uff0c\u6548\u679c\u4e00\u6837\u3002<\/p>\n<p>\u540c\u6837\u7684\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int * const a;<\/pre>\n<p>\u548c<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">const int * b;\r\nint const * c;<\/pre>\n<p>\u5168\u7136\u4e0d\u540c\u3002<\/p>\n<p>\u8ba9\u6211\u4eec\u5957\u7528\u300c\u66ff\u6362\u300d\u7684\u89c2\u70b9\u2014\u2014int const * c \u8868\u793a *c \u662f\u4e00\u4e2a int const\uff08\u76f8\u5e94\u5730\uff0c\u5bf9\u4e8e b \u662f const int\uff0c\u4e5f\u5c31\u662f int const\uff09\uff0c\u5c31\u662f\u8bf4\uff0cc \u662f\u4e00\u4e2a\u6307\u5411\u6574\u6570\u5e38\u91cf\u7684\u6307\u9488\uff0c\u4f46\u662f c \u672c\u8eab\u4e0d\u662f\u4e00\u4e2a\u5e38\u91cf\uff0c\u662f\u53ef\u4ee5\u968f\u4fbf\u6539\u7684\u3002<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int v = 5;\r\nint const * c = &amp;v; \/\/ NULL \u8868\u793a 0\u3002\u4e0d\u4f1a\u62a5\u9519\uff0c\u56e0\u4e3a c \u53ef\u53d8\u3002\r\n*c = 7; \/\/ \u4f1a\u62a5\u9519\uff0c\u56e0\u4e3a `*c` \u4e0d\u53ef\u53d8\u3002<\/pre>\n<p>\u800c int * const a\uff0c\u5219\u662f\u88ab const \u4fee\u9970\u7684 int *\uff0c\u4e5f\u5c31\u662f\u4e0d\u53ef\u53d8\u7684\u6574\u6570\u6307\u9488\uff0ca \u672c\u8eab\u662f\u5e38\u91cf\uff0c\u4e0d\u80fd\u6539\uff0c\u6307\u5411\u7684\u5730\u65b9\u5012\u662f\u53ef\u4ee5\u6539\u3002<\/p>\n<p>\u90a3\u4e48 const \u5982\u4f55\u63cf\u8ff0\u4e00\u4e2a\u300c\u4e0d\u53ef\u53d8\u300d\u6570\u7ec4\uff1fconst \u8be5\u653e\u5230\u6570\u7ec4\u58f0\u660e\u54ea\u91cc\u5462\uff1f\u597d\u50cf\u6ca1\u6709\u5730\u65b9\u53ef\u4ee5\u653e\u54e6\u3002<\/p>\n<p>\u4ec0\u4e48\uff1f\u5e38\u91cf\u6570\u7ec4\uff1f\u4e0d\u5b58\u5728\u8fd9\u79cd\u4e1c\u897f\u3002\u6211\u4eec\u77e5\u9053\u6570\u7ec4\u662f\u4e0d\u53ef\u8d4b\u503c\u7684\uff0c\u53ea\u80fd\u81f3\u591a\u5b9a\u4e49\u4e00\u6b21\uff0c\u5b83\u672c\u8eab\u5c31\u662f\u4e0d\u53ef\u53d8\u7684\uff0c\u6240\u4ee5\u6ca1\u6709 const \u4e5f\u5f88\u79d1\u5b66\u3002<\/p>\n<p>\u300c\u4e0d\u53ef\u53d8\u300d\u51fd\u6570\u4e5f\u662f\u4e0d\u5b58\u5728\u7684\uff0c\u7406\u7531\u540c\u4e0a\u3002\u5f53\u7136\u51fd\u6570\u7684\u8fd4\u56de\u7c7b\u578b\u548c\u53c2\u6570\u7c7b\u578b\u90fd\u53ef\u4ee5\u662f const \u7684\uff0c\u5f88\u5bb9\u6613\u4e3e\u4e00\u53cd\u4e09\u3002<\/p>\n<h2>typedef<\/h2>\n<p>typedef \u5f88\u6709\u7528\uff0c\u5b83\u53ef\u80fd\u662f\u6211\u4eec\u201c\u53ef\u8bfb\u201d\u5730\u58f0\u660e\u8fd9\u4e9b\u590d\u6742\u7c7b\u578b\u7684\u65b9\u6848\u3002\u90a3\u4e48\u5982\u4f55 typedef \u8fd9\u4e9b\u590d\u6742\u7c7b\u578b\u7684\uff1f<\/p>\n<p>\u4f60\u53ef\u80fd\u89c1\u8fc7<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">typedef int a;<\/pre>\n<p>\u5b83\u628a a \u58f0\u660e\u4f5c int \u7c7b\u578b\u7684\u522b\u540d\u3002 \u4f60\u4e5f\u53ef\u80fd\u89c1\u8fc7<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">typedef long long LL;<\/pre>\n<p>\u5b83\u628a LL \u58f0\u660e\u4f5c long long \u7c7b\u578b\uff08\u6ce8\u610f long long \u662f<b>\u4e00\u4e2a<\/b>\u7c7b\u578b\uff09\u7684\u522b\u540d\u3002<\/p>\n<p>\u8fd9\u4e9b\u90fd\u662f\u7b80\u5355\u7c7b\u578b\uff0c\u90a3\u4e48\u590d\u6742\u7c7b\u578b\u5462\uff1f\u5176\u5b9e\u548c\u4e0a\u9762\u4e00\u6a21\u4e00\u6837\u5c31\u53ef\u4ee5\u4e86\u3002\u4f60\u53ef\u4ee5\u628a\u4efb\u4f55\u4e00\u4e2a\u53d8\u91cf\u58f0\u660e\u8bed\u53e5\u4e4b\u524d\u52a0\u4e0a typedef\uff0c\u4ece\u800c\u83b7\u5f97\u4e00\u4e2a\u7c7b\u578b\u522b\u540d\u58f0\u660e\u3002\u672c\u6765\u8981\u58f0\u660e\u7684\u300c\u53d8\u91cf\u300d\u540d\uff0c\u5c31\u662f\u73b0\u5728\u58f0\u660e\u7684\u300c\u7c7b\u578b\u522b\u540d\u300d\u3002\u6bd4\u5982\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">typedef int (*a[9])[5];<\/pre>\n<p>\u5c31\u662f\u628a a \u58f0\u660e\u4f5c\u6570\u7ec4\u7684\u6307\u9488\u7684\u6570\u7ec4\u3002\u4ee5\u540e\u53ef\u4ee5\u50cf<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">a v_a;<\/pre>\n<p>\u8fd9\u6837\u58f0\u660e\u4e00\u4e2a\u540d\u4e3a v_a \u7684\u300c\u6570\u7ec4\u7684\u6307\u9488\u7684\u6570\u7ec4\u300d\u3002\u4e3a\u4e86\u589e\u52a0\u53ef\u8bfb\u6027\uff0c\u4f60\u53ef\u4ee5\u591a\u4f7f\u7528\u6e10\u8fdb\u7684 typedef\uff0c\u6bcf\u6b21\u53ea\u591a\u5b9a\u4e49\u4e00\u5c42\u2014\u2014\u6bd4\u5982\u7b2c\u4e00\u6b21\u5b9a\u4e49\u4e00\u4e2a\u6570\u7ec4\u7c7b\u578b\uff0c\u7b2c\u4e8c\u6b21\u5b9a\u4e49\u6307\u5411\u7b2c\u4e00\u6b21\u90a3\u7c7b\u578b\u7684\u6307\u9488\uff0c\u7b2c\u4e09\u6b21\u5b9a\u4e49\u7b2c\u4e8c\u6b21\u90a3\u7c7b\u578b\u7684\u6570\u7ec4\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">typedef int int_array[5];\r\ntypedef int_array * ptr_to_int_array;\r\ntypedef ptr_to_int_array array_of_ptr_to_int_[7];<\/pre>\n<p>\uff08\u8bf4\u5b9e\u8bdd\uff0c\u5de5\u7a0b\u4e0a\u8fd9\u6837\u6709\u591a\u5927\u610f\u4e49\uff0c\u751a\u81f3\u662f\u5426\u9700\u8981\u8fd9\u6837\u7684\u590d\u6742\u7c7b\u578b\uff0c\u90fd\u662f\u6709\u4e89\u8bae\u7684\u3002\u4e0d\u540c\u7684\u4eba\u6709\u4e0d\u540c\u7684\u770b\u6cd5\u3002\u6bd4\u5982 Linux \u5185\u6838\u90a3\u4e00\u5366\u7684\u4eba\u5c31\u4e0d\u4e3b\u5f20\u5bf9 struct \u8fdb\u884c typedef\uff0c\u800c libuv \u91cc\u8fd9\u6837\u7684 typedef \u53c8\u6ee1\u5929\u98de\u3002\u53c8\u6bd4\u5982\u5f88\u591a\u4eba\u4e0d\u4e3b\u5f20\u5bf9\u6307\u9488\u7c7b\u578b\u8fdb\u884c typedef\u3002\u5de5\u7a0b\u4e60\u60ef\u4e0a\u7684\u4e89\u8bba\uff0c\u662f\u6c38\u4e0d\u8fc7\u65f6\u7684\u8bae\u9898\u3002\uff09<\/p>\n<h2>\u7f51\u6613\u7b14\u8bd5\u9898<\/h2>\n<p>\u524d\u4e00\u9635\u5b50\uff0c\u67d0\u7f51\u6613\u6821\u62db\u7b14\u8bd5\u9898\u5f15\u8d77\u4e86\u8f69\u7136\u5927\u6ce2\uff0c\u53d7\u5230\u5e7f\u6cdb\u5410\u69fd\u3002\u5bf9\u9898\u76ee\u7684\u4ef7\u503c\u53d6\u5411\u6211\u4eec\u6682\u4e14\u4e0d\u8868\uff0c\u4e0d\u59a8\u7528\u521a\u521a\u8ba8\u8bba\u8fc7\u7684\u5185\u5bb9\u6765\u8bd5\u7740\u5206\u6790\u4e00\u4e0b\u3002\u5b83\u662f C++\uff0c\u4e0d\u8fc7\u4e0d\u8d85\u51fa C \u7684\u8303\u7574\uff08C++ \u5f15\u5165\u4e86\u7c7b\u548c\u6a21\u677f\uff0c\u76f8\u5173\u60c5\u5f62\u5bf9\u7c7b\u578b\u7684\u89e3\u6790\u4f1a\u590d\u6742\u5f97\u591a\uff09\u3002\u9898\u76ee\u662f\u5206\u6790\u8fd9\u51e0\u4e2a\u7c7b\u578b\u7684\u610f\u4e49\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int *ptr[n];\r\n\r\nint (*)ptr[n];\r\n\r\nint *ptr();\r\n\r\nint (*)ptr();\r\n\r\nint(*((*ptr(int, int))))(int);<\/pre>\n<p>\u6211\u4eec\u5148\u6982\u89c8\u4e00\u4e0b\uff0c\u5176\u4e2d\u6709\u4e24\u4e2a\u663e\u8457\u7684\u9519\u8bef\u2014\u2014(*)\u662f\u975e\u6cd5\u7684\uff0c\u628a\u4e00\u4e2a\u8fd9\u6837\u7684\u788e\u7247\u5355\u72ec\u62ec\u8d77\u6765\u662f\u6ca1\u6709\u610f\u4e49\u7684\u3002\uff08\u5f15\u7528\u6807\u51c6\uff09\u5b9e\u9645\u4e0a\u6807\u51c6\u4e2d\u4e5f\u4e0d\u5141\u8bb8\u51fa\u73b0\u8fd9\u6837\u7684\u60c5\u51b5\uff0c\u6240\u4ee5\u7f16\u8bd1\u5668\u5f53\u7136\u4e5f\u4f1a\u62a5\u9519\u4e86\u3002\u6211\u4eec\u4e0d\u59a8\u731c\u6d4b\u4e00\u4e0b\uff0c\u539f\u672c\u7684\u9762\u8c8c\u662f (*ptr) \u800c\u4e0d\u662f *(ptr)\uff0c\u8fd9\u5c31\u5f88\u6709\u610f\u4e49\u4e86\uff0c2\u30015 \u6539\u8fc7\u4e4b\u540e\u770b\u8d77\u6765\u4e5f\u4e0d\u8ddf\u522b\u7684\u9009\u9879\u91cd\u590d\uff0c\u5f88\u5408\u7406\u3002<\/p>\n<p>\u6211\u4eec\u6765\u770b\u6539\u8fc7\u540e\u7684\u6837\u8c8c\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int *ptr[n];\r\n\r\nint (*ptr)[n];\r\n\r\nint *ptr();\r\n\r\nint (*ptr)();\r\n\r\nint(*((*ptr(int, int))))(int);<\/pre>\n<p>\u8fd9\u4e48\u770b\u6765\uff0c\u7b2c 1\u30012 \u9879\u6211\u4eec\u5728\u6700\u5f00\u59cb\u5c31\u8ba8\u8bba\u5b8c\u4e86\u3002\u7b2c 3\u30014 \u9879\u4e5f\u90fd\u662f\u6700\u57fa\u672c\u7684\u60c5\u5f62\u3002\u770b\u770b\u7b2c\u4e94\u9879\uff0c\u6211\u4eec\u5e94\u8be5\u4ece\u5185\u800c\u5916\u5730\u770b\uff0cptr \u662f\u4e00\u4e2a\u51fd\u6570\uff08\u6211\u4eec\u524d\u9762\u8bf4\u8fc7\uff0c\u53c2\u6570\u5217\u8868\u6bd4\u661f\u53f7\u66f4\u9ad8\u7ea7\uff0c\u8fd9\u91cc\u4e0d\u662f(*ptr)(int, int)\uff0c\u800c\u662f*ptr(int, int)\u3002<\/p>\n<p>\u5b83\u63a5\u6536\u4e24\u4e2a\u90fd\u4e3a int \u7c7b\u578b\u7684\u53c2\u6570\u3002\u90a3\u4e48\u5b83\u7684\u8fd4\u56de\u7c7b\u578b\u662f\u4ec0\u4e48\u5462\uff1f\u8bb0\u4f4f\u6211\u4eec\u5f53\u65f6\u662f\u600e\u4e48\u58f0\u660e\u51fd\u6570\u7c7b\u578b\u7684\uff1f\u628a ptr(int, int) \u770b\u4f5c\u4e00\u4e2a\u6574\u4f53\uff0c\u5b83\u88ab\u58f0\u660e\u7684\u7c7b\u578b\uff0c\u5c31\u662f\u5b83\u7684\u8fd4\u56de\u7c7b\u578b\u3002\u6211\u4eec\u7528 c \u4ee3\u8868\u5b83\u7684\u8bdd\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int(*((*c)))(int);<\/pre>\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u6709\u4e24\u5bf9\u591a\u4f59\u7684\u62ec\u53f7\uff0c\u6211\u4eec\u6765\u5220\u51cf\u5b83\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int(**c)(int);<\/pre>\n<p>c \u662f\u4e00\u4e2a\u6307\u5411\u3010\u51fd\u6570\u6307\u9488\u3011\u7684\u6307\u9488\uff08\u4e8c\u91cd\u6307\u9488\uff09\uff0c\u8fd9\u6b21\u6211\u4eec\u4e0d\u60f3\u4e00\u6b65\u4e00\u6b65\u5199\u4e86\uff0c\u5c31\u8111\u8865\u5427\u3002\u8fd9\u4e2a\u3010\u51fd\u6570\u6307\u9488\u3011\u6307\u5411\u7684\u51fd\u6570\u63a5\u6536\u4e00\u4e2a int \u7c7b\u578b\u7684\u53c2\u6570\uff0c\u8fd4\u56de\u4e00\u4e2a int \u7c7b\u578b\u7684\u7ed3\u679c\u3002<\/p>\n<p>\u7efc\u4e0a\u6240\u8ff0\uff0cptr \u662f\u4e00\u4e2a\u51fd\u6570\uff0c\u8fd9\u4e2a\u51fd\u6570\u63a5\u6536\u4e24\u4e2a\u7c7b\u578b\u4e3a int \u7684\u53c2\u6570\uff0c\u8fd4\u56de\u4e00\u4e2a\u6307\u5411\u3010\u51fd\u6570\u6307\u9488\u3011\u7684\u6307\u9488\uff0c\u7b2c\u4e8c\u4e2a\u51fd\u6570\u63a5\u6536\u4e00\u4e2a\u7c7b\u578b\u4e3a int\u7684\u53c2\u6570\uff0c\u8fd4\u56de\u4e00\u4e2a int \u7c7b\u578b\u7684\u7ed3\u679c\u3002<\/p>\n<p>\u8fd9\u5bf9\u5417\uff1f\u6211\u4eec\u4e0d\u59a8\u7528\u4ee3\u7801\u6765\u786e\u8bc1\uff0c\u5982\u679c\u6309\u7167\u8fd9\u6837\u7684\u601d\u8def\u5199\u51fa\u7684\u4ee3\u7801\u80fd\u7f16\u8bd1\uff0c\u6211\u4eec\u5c31\u5bf9\u4e86\uff1a<\/p>\n<pre class=\"prettyprint lang-c_cpp\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">int unary(int a) {\r\n  return a + 1;\r\n}\r\n\r\nint (*p_unary)(int a) = unary;\r\n\r\nint(*((*ptr(int a, int b))))(int) {\r\n  return &amp;p_unary;\r\n}<\/pre>\n<p>\u7f16\u8bd1\u901a\u8fc7\uff0c\u5927\u529f\u544a\u6210\uff01<\/p>\n<h2>\u7262\u9a9a<\/h2>\n<p>C \u8bed\u8a00\u7684\u7c7b\u578b\u58f0\u660e\uff0c\u5e26\u6765\u4e86\u8bb8\u591a\u50cf\u8fd9\u6837\u7684\u9ebb\u70e6\u3002\u8bf8\u5982 Scala \u548c TypeScript \u4e4b\u7c7b\u7684\u4e00\u90e8\u5206\u73b0\u4ee3\u8bed\u8a00\uff0c\u9009\u62e9\u4e86\u540e\u7f6e\u7c7b\u578b\u58f0\u660e\uff0c\u6bd4\u5982 a : int = 3\uff08\u793a\u610f\uff0c\u4e0d\u662f\u8fd9\u4e24\u79cd\u8bed\u8a00\u7684\u4ee3\u7801\uff09\u4ee3\u66ff\u4e86 int a = 3\uff0c\u800c char func(int a, double b) \u5219\u88ab func (a: int, b: double) -&gt; char \u4ee3\u66ff\u3002\u4e00\u4e2a\u8fd4\u56de\u51fd\u6570\u7684\u51fd\u6570\uff0c\u53ef\u80fd\u53ef\u4ee5\u5199\u4f5c d_func(a: int) -&gt; (func(b: int) -&gt; int)\u3002\u5f53\u7136 C \u8bed\u8a00\u91cc\u4e0d\u53ef\u4ee5\u8fd9\u4e48\u505a\uff0c\u51fd\u6570\u662f\u4e0d\u53ef\u4ee5\u8fd4\u56de\u7684\u3002\u53ea\u80fd\u8fd4\u56de\u51fd\u6570\u6307\u9488\uff0c\u6bd4\u5982 int (*(d_func(int a)))(int b)<\/p>\n<p>\u5176\u5b9e\u540e\u7f6e\u7684\u597d\u5904\u5012\u6ca1\u6709\u90a3\u4e48\u4e3b\u8981\uff0c\u867d\u7136\u5411\u53f3\u7684\u7bad\u5934\u66f4\u7b26\u5408\u5927\u591a\u6570\u4eba\u7684\u9605\u8bfb\u4e60\u60ef\uff0c\u6bd5\u7adf\u524d\u7f6e\u53ef\u4ee5\u770b\u6210\u662f\u540e\u7f6e\u7684\u5b8c\u5168\u5bf9\u5076\u3002C \u8bed\u8a00\u7684\u9ebb\u70e6\u5728\u4e8e\u4e24\u4e2a\uff1a<\/p>\n<p>\u4e00\u4e2a\u662f\uff0c\u867d\u7136\u5de6\u53f3\u53ef\u4ee5\u5b8c\u5168\u5bf9\u5076\uff0c\u4f46\u662f C \u8bed\u8a00\u7684\u53c2\u6570\u5217\u8868\u5728\u53f3\u8fb9\uff0c\u7c7b\u578b\u5374\u5728\u5de6\u8fb9\uff0c\u53c2\u6570\u7684\u7c7b\u578b\uff0c\u5b83\u4eec\u88ab\u51fd\u6570\u540d\u5206\u5f00\u4e86\uff0c\u65e0\u6cd5\u5efa\u7acb\u7bad\u5934\u90a3\u4e48\u76f4\u89c2\u7684\u8ba4\u8bc6\u3002\u5982\u679c\u53c2\u6570\u5217\u8868\u524d\u7f6e\u5012\u4e5f\u597d\uff1aint &lt;- (int b) (*( &lt;- (int a) d_func))\u3002\u867d\u7136\u4ece\u53f3\u5411\u5de6\u6709\u4e9b\u4e0d\u4e60\u60ef\uff0c\u4f46\u662f\u662f\u4e0d\u662f\u597d\u50cf\u6709\u4e9b\u611f\u89c9\u4e86\uff1f<\/p>\n<p>\u53e6\u4e00\u4e2a\u662f\uff0c\u6570\u7ec4\u7684\u58f0\u660e\uff0c\u5143\u7d20\u7c7b\u578b\u5728\u5de6\u8fb9\uff0c\u957f\u5ea6\u5374\u5728\u53f3\u8fb9\u3002\u8fd9\u5176\u5b9e\u8ddf\u7b2c\u4e00\u4e2a\u9ebb\u70e6\u662f\u4e00\u56de\u4e8b\uff0c\u6240\u4ee5\u5f88\u591a\u8bed\u8a00\u5f15\u5165\u4e86\u5f62\u5982 int[5] a \u7684\u8bed\u6cd5\uff0c[5] \u76f4\u63a5\u4fee\u9970 int\uff0c\u770b\u8d77\u6765\u5c31\u8981\u76f4\u89c2\u5f97\u591a\uff0c\u6bd4\u5982 int (*a[9])[5] \u5c31\u53d8\u6210\u4e86 ((int[5])*)[9] a\uff0c\u8fd9\u6837\u770b\u8d77\u6765\u6beb\u4e0d\u8d39\u529b\uff0c\u975e\u5e38\u76f4\u89c2\uff0c\u4e0d\u9700\u8981\u4efb\u4f55\u5b66\u4e60\u3002<\/p>\n<p>\u5f53\u7136\u5f88\u591a\u5176\u4ed6\u8bed\u8a00\u90fd\u6ca1\u6709\u6307\u9488\uff0c\u8fd9\u4e5f\u4f1a\u8ba9\u7c7b\u578b\u58f0\u660e\u770b\u8d77\u6765\u66f4\u7b80\u6d01\u3002\u4e0d\u8fc7\u8fd9\u4e0d\u662f\u4e3b\u8981\u7684\uff0c\u56e0\u4e3a C \u8bed\u8a00\u7684\u6307\u9488\u58f0\u660e\uff0c\u57fa\u672c\u8fd8\u662f\u5408\u7406\u7684\u3002\u5f53\u7136 TypeScript \u8fd8\u662f\u7565\u6709\u7e41\u7410\uff0c\u5b83\u7684\u7c7b\u578b\u58f0\u660e\u5fc5\u987b\u8981\u6307\u51fa\u53c2\u6570\u540d\uff0c\u6bd4\u5982\uff1a<\/p>\n<pre class=\"prettyprint lang-typescript\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">function map&lt;A, B&gt;(func: (a: A) =&gt; B, elem: A): B;<\/pre>\n<p>\u8fd9\u65e0\u7591\u662f\u589e\u52a0\u4e86\u9605\u8bfb\u96be\u5ea6\uff0c\u867d\u7136\u6bd4\u8d77 C \u5df2\u7ecf\u5f88\u4f4e\u4e86\uff0c\u4f46\u662f\u9762\u5bf9\u9ad8\u9636\u51fd\u6570\u7c7b\u578b\uff0c\u8fd8\u662f\u663e\u5f97\u529b\u4e0d\u4ece\u5fc3\uff08C \u8bed\u8a00\u6839\u672c\u6ca1\u8fd9\u4e2a\u9700\u6c42\uff0c\u56e0\u4e3a\u5b83\u4e0d\u652f\u6301\u5c31\u5730\u5730\u3001\u5d4c\u5957\u5730\u521b\u5efa\u51fd\u6570\uff0c\u867d\u7136\u53ef\u4ee5\u6709\u9ad8\u9636\u51fd\u6570\u7b7e\u540d\uff0c\u4f46\u662f\u6839\u672c\u6ca1\u6709\u5b9e\u7528\u4ef7\u503c\u3002\u867d\u7136\u6709\u4e00\u4e9b GNU \u6269\u5c55\uff0c\u4f46\u662f\u624b\u52a8\u7ba1\u7406\u5185\u5b58\u4e5f\u4f1a\u8ba9\u9ad8\u9636\u51fd\u6570\u82e6\u4e0d\u582a\u8a00\uff09\u3002<\/p>\n<p>Scala \u867d\u7136\u652f\u6301\u4e0d\u9700\u8981\u5bf9\u9ad8\u9636\u51fd\u6570\u6807\u6ce8\u53c2\u6570\u540d\uff0c\u4f46\u51fd\u6570\u672c\u8eab\u7684\u53c2\u6570\u5217\u8868\u548c\u7c7b\u578b\u7b7e\u540d\u8fd8\u662f\u8026\u5408\u7684\u3002\u800c\u8bf8\u5982 OCaml \u4e4b\u7c7b\u7684 ML \u7cfb\u8bed\u8a00\uff0c\u4ee5\u53ca\u6df1\u53d7\u5176\u5f71\u54cd\u7684 Haskell\uff08\u5bb6\u65cf\uff0c\u5305\u62ec Idris, Agda \u7b49\uff09\uff0c\u91c7\u53d6\u4e86\u66f4\u6fc0\u8fdb\u7684\u3001\u51fd\u6570\u7c7b\u578b\u7b7e\u540d\u548c\u51fd\u6570\u5b9e\u4f53\u5b8c\u5168\u5206\u5f00\u7684\u7b56\u7565\uff0c\u53ef\u4ee5\u8f7b\u677e\u58f0\u660e\u590d\u6742\u7c7b\u578b\uff0c\u6bd4\u5982\u6700\u5e38\u7528\u7684\u51fd\u6570 foldr \u957f\u8fd9\u6837\uff1a<\/p>\n<pre class=\"prettyprint lang-haskell\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">foldr :: Foldable t =&gt; (a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b<\/pre>\n<p>\u7c7b\u578b\u4e4b\u95f4\u7684\u5173\u7cfb\u663e\u5f97\u5341\u5206\u6e05\u6670\u660e\u4e86\u3002\u8fd9\u5c06\u6211\u4eec\u5e26\u5165\u4e86\u4e00\u4e2a\u73a9\u5f04\u7c7b\u578b\u7684\u4e16\u754c\u3002\u4e0d\u8fc7\u8fd9\u90fd\u662f\u540e\u8bdd\u4e86\u3002<\/p>\n<p>\u4ece\u8fd9\u70b9\u4e0a\u6765\u770b\uff0c\u7531\u4e8e\u58f0\u660e\u65f6\u53ef\u4ee5\u5b8c\u5168\u7701\u7565\u53c2\u6570\u540d\uff0c C \u8bed\u8a00\u53cd\u800c\u663e\u5f97\u6bd4 Scala \u548c TypeScript \u5148\u8fdb\u3002\u53ef\u662f\u5728\u540e\u7eed\u5b9e\u73b0\u8fd9\u4e2a\u51fd\u6570\u7684\u65f6\u5019\uff0c\u8fd8\u662f\u8981\u7167\u6284\u7c7b\u578b\uff0c\u800c\u4e0d\u80fd\u6839\u636e\u53c2\u6570\u4f4d\u7f6e\u81ea\u52a8\u63a8\u5bfc\u51fa\uff08\u4e0d\u5199\u4f1a\u88ab\u9ed8\u8ba4\u4e3a int\uff09\uff0c\u4e0d\u514d\u663e\u5f97\u6709\u4e9b\u9057\u61be\u2014\u2014\u7136\u800c\u8fd9\u4e4b\u4e2d\u4e5f\u6709\u5fc5\u7136\u3002\u4e2a\u4e2d\u8be6\u60c5\uff0c\u8db3\u591f\u7545\u8c08\u6570\u65e5\uff0c\u8fd9\u91cc\u65e0\u6687\u53d9\u8ff0\u3002<\/p>\n<h2>\u7ec3\u4e60<\/h2>\n<p>\u5728 <a class=\" wrap external\" href=\"https:\/\/link.zhihu.com\/?target=https%3A\/\/www.codewars.com\/kata\/c-puzzle-pointer-monster\/train\/c\" target=\"_blank\" rel=\"nofollow noreferrer noopener\">C Puzzle: Pointer Monster<i class=\"icon-external\"><\/i><\/a> \u5b9a\u4e49\u5404\u79cd\u590d\u6742\u7c7b\u578b\uff0c\u8fdb\u884c\u4e0b\u6807\u8fd0\u7b97\uff0c\u5e76\u901a\u8fc7\u6d4b\u8bd5\u3002<\/p>\n<h2>\u5e7f\u544a\u65f6\u95f4<\/h2>\n<p><span class=\"RichText CopyrightRichText-richText\"><img class=\"origin_image zh-lightbox-thumb\" src=\"https:\/\/colliot.me\/wp-content\/uploads\/2017\/11\/v2-a3810f50127ebd430d5793bebce73e1e_b.jpg\" width=\"712\" data-caption=\"\" data-rawwidth=\"712\" data-rawheight=\"209\" data-original=\"https:\/\/pic3.zhimg.com\/50\/v2-a3810f50127ebd430d5793bebce73e1e_r.jpg\" \/><\/span><a class=\" wrap external\" href=\"https:\/\/link.zhihu.com\/?target=http%3A\/\/www.codewars.com\/r\/KvWTsA\" target=\"_blank\" rel=\"nofollow noreferrer noopener\">Codewars.com<i class=\"icon-external\"><\/i><\/a> \u662f\u4e00\u4e2a\u5f88\u597d\u7684\u7efc\u5408\u6027\u3001\u6e38\u620f\u5316 OJ\uff0c\u9664\u4e86\u7b97\u6cd5\uff08\u591a\u662f\u5165\u95e8\u7ea7\u7684\uff09\u4e4b\u5916\uff0c\u8003\u5bdf\u8bed\u8a00\u7279\u6027\uff08\u8f83\u4e3a\u6df1\u5165\uff09\u662f\u5176\u4e00\u5927\u4eae\u70b9\uff0c\u540c\u65f6\u6709\u5f88\u591a Haskell \u65b9\u9762\u7684\u5185\u5bb9\uff0c\u5305\u62ec\u6211\u4eec\u559c\u95fb\u4e50\u89c1\u7684\u8bfb\u8bba\u6587\u7136\u540e\u5b8c\u5f62\u586b\u7a7a\u3002\u9898\u56fe\u662f Codewars \u4e0a\u4e0a\u8ff0\u7ec3\u4e60\u7684\u754c\u9762\u622a\u56fe\u3002<\/p>\n<h2>\u540e\u8bb0<\/h2>\n<p>\u4ee5\u4e0a\u5185\u5bb9\uff0c\u90fd\u662f\u57fa\u4e8e C \u8bed\u8a00\u6807\u51c6\u6f14\u7ece\u800c\u6210\uff08<a class=\" wrap external\" href=\"https:\/\/link.zhihu.com\/?target=http%3A\/\/www.open-std.org\/jtc1\/sc22\/wg14\/www\/docs\/n1548.pdf\" target=\"_blank\" rel=\"nofollow noreferrer noopener\">C11 draft N1548<i class=\"icon-external\"><\/i><\/a>\uff0c\u514d\u8d39\uff0c\u6b63\u5f0f\u7248\u662f\u4ed8\u8d39\u7684\uff09\u3002\u4f5c\u4e3a\u4e00\u7bc7\u5165\u95e8\u7ea7\u7684\u5c0f\u54c1\u6587\uff0c\u4e3a\u4e86\u9605\u8bfb\u6548\u679c\uff0c\u6211\u9009\u62e9\u4e0d\u8be6\u8ff0\u8fc7\u7a0b\u548c\u539f\u6587\u3002\u6c34\u5e73\u6709\u9650\uff0c\u9519\u8bef\u4e4b\u5904\u5728\u6240\u96be\u514d\uff0c\u6b22\u8fce\u8bfb\u8005\u6307\u6b63\u3002<\/p>\n<\/div>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Sorry, this entry is only available in \u4e2d\u6587. For the sake of viewer convenience, the content is shown below in the alternative language. You may click the link to switch the active language. C \u8bed\u8a00\u7684\u7c7b\u578b\u58f0\u660e\uff0c\u7531\u4e8e\u67d0\u4e9b\u5386\u53f2\u5c40\u9650\u6027\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u663e\u5f97\u76f8\u5f53\u590d\u6742\u3002\u4e0b\u9762\u8ba9\u6211\u4eec\u6765\u6e10\u6e10\u6df1\u5165 C \u8bed\u8a00\u7c7b\u578b\u58f0\u660e\u7684\u8c1c\u56e2\uff0c\u4e00\u63a2\u7a76\u7adf\u3002 &nbsp; \u6307\u9488\u548c\u6570\u7ec4 \u4e00\u91cd\u58f0\u660e \u4ee5\u4e0b\u8fd9\u4e9b\u95ee\u9898\uff0c\u6211\u76f8\u4fe1\u5373\u4f7f\u662f\u6700\u57fa\u672c\u7684\u521d\u5b66\u8005\u4e5f\u4e0d\u4f1a\u6709\u592a\u5927\u56f0\u96be\uff1a \u4f60\u4f1a\u58f0\u660e\u6570\u7ec4\u5417\uff1f int a[5]; \/\/ \u5305\u542b 5 \u4e2a\u5143\u7d20\u3002 \u4f60\u4f1a\u58f0\u660e\u6307\u9488\u5417\uff1f int *a; \u4e8c\u91cd\u58f0\u660e \u4f60\u4f1a\u58f0\u660e\u53cc\u91cd\u6307\u9488\u5417\uff1f<\/p>\n","protected":false},"author":1,"featured_media":385,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[31,33,32,24],"_links":{"self":[{"href":"https:\/\/colliot.org\/en\/wp-json\/wp\/v2\/posts\/383"}],"collection":[{"href":"https:\/\/colliot.org\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/colliot.org\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/colliot.org\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/colliot.org\/en\/wp-json\/wp\/v2\/comments?post=383"}],"version-history":[{"count":6,"href":"https:\/\/colliot.org\/en\/wp-json\/wp\/v2\/posts\/383\/revisions"}],"predecessor-version":[{"id":439,"href":"https:\/\/colliot.org\/en\/wp-json\/wp\/v2\/posts\/383\/revisions\/439"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/colliot.org\/en\/wp-json\/wp\/v2\/media\/385"}],"wp:attachment":[{"href":"https:\/\/colliot.org\/en\/wp-json\/wp\/v2\/media?parent=383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/colliot.org\/en\/wp-json\/wp\/v2\/categories?post=383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/colliot.org\/en\/wp-json\/wp\/v2\/tags?post=383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}