{"id":184,"date":"2023-11-20T17:25:14","date_gmt":"2023-11-20T09:25:14","guid":{"rendered":"http:\/\/124.220.62.22\/?p=184"},"modified":"2024-01-23T16:04:42","modified_gmt":"2024-01-23T08:04:42","slug":"%e8%ae%ba%e6%8c%87%e9%92%88","status":"publish","type":"post","link":"http:\/\/blog.chxzking.cn\/index.php\/2023\/11\/20\/%e8%ae%ba%e6%8c%87%e9%92%88\/","title":{"rendered":"\u8bba\u6307\u9488"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u524d\u8a00<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">\u8fd0\u884c\u73af\u5883\uff1a<code>centos7<\/code>\uff08 <code>Linux<\/code>\uff09 \u7f16\u8bd1\u5668: <code>gcc 9.3.1<\/code><\/mark> <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">64\u4f4d<\/mark><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6307\u9488\u662f\u4ec0\u4e48<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5730\u5740\u662f\u5185\u5b58\u7a7a\u95f4\u5bf9\u5e94\u7684\u7f16\u53f7\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6307\u9488\u5c31\u662f\u5730\u5740\uff01<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6307\u9488\u4f5c\u4e3ac\u8bed\u8a00\u6700\u96be\u7684\u8bed\u6cd5\u4e4b\u4e00\uff0c\u4e5f\u662fC\u8bed\u8a00\u548cc++\u7684\u7279\u8272\u4e4b\u4e00\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6307\u9488\u53d8\u91cf\uff08pointer\uff09\u662f\u4e00\u79cd\u57fa\u672c\u6570\u636e\u7c7b\u578b\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6307\u9488\u53d8\u91cf\u548c\u666e\u901a\u53d8\u91cf\u6700\u672c\u8d28\u7684\u533a\u522b\u662f\u2014\u2014\u666e\u901a\u53d8\u91cf\u5b58\u653e\u7684\u662f\u4e00\u4e2a\u503c\uff0c\u800c\u6307\u9488\u53d8\u91cf\u5b58\u653e\u7684\u662f\u4e00\u4e2a\u5185\u5b58\u5730\u5740\u3002\u6bcf\u4e00\u4e2a\u53d8\u91cf\u5177\u6709\u4e24\u4e2a\u610f\u4e49\uff0c\u4e00\u4e2a\u662f\u503c\uff0c\u4e00\u4e2a\u662f\u5730\u5740\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u53d8\u91cf\u5c31\u76f8\u5f53\u4e8e\u4e00\u95f4\u516c\u5bd3\uff0c\u503c\u5c31\u662f\u4f4f\u5728\u91cc\u9762\u7684\u4eba\uff0c\u5730\u5740\u5c31\u662f\u516c\u5bd3\u7684\u95e8\u724c\u53f7\u3002\u5728\u751f\u6d3b\u4e2d\uff0c\u6211\u4eec\u65e2\u53ef\u4ee5\u76f4\u63a5\u6253\u7535\u8bdd\u5c06\u516c\u5bd3\u4e2d\u7684\u670b\u53cb\u7ea6\u51fa\u6765\u89c1\u9762\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5bfb\u627e\u95e8\u724c\u53f7\uff0c\u5728\u95e8\u724c\u5bf9\u5e94\u7684\u623f\u95f4\u4e2d\u89c1\u9762\uff0c\u867d\u7136\u8fc7\u7a0b\u4e0d\u540c\uff0c\u4f46\u7ed3\u679c\u90fd\u662f\u89c1\u5230\u4e86\u670b\u53cb\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u540c\u7406\uff0c\u6211\u4eec\u5728\u8bbf\u95ee\u53d8\u91cf\u7684\u65f6\u5019\uff0c\u65e2\u53ef\u4ee5\u901a\u8fc7\u53d8\u91cf\u540d\u76f4\u63a5\u8bbf\u95ee\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5b83\u7684\u5730\u5740\u95f4\u63a5\u8bbf\u95ee\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9a\u4e49\u6307\u9488<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u6307\u9488\u7684\u58f0\u660e\u4e0e\u91ce\u6307\u9488<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u5b9e\u9645\u64cd\u4f5c\u4e2d\uff0c\u4eba\u4eec\u5f80\u5f80\u5c06\u6307\u9488\u548c\u6307\u9488\u53d8\u91cf\u901a\u5e38\u4e3a\u6307\u9488\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7\u524d\u9762\u7684\u5b66\u4e60\uff0c\u6211\u4eec\u77e5\u9053\u4e86\u5982\u4f55\u5b9a\u4e49\u4e00\u4e2a\u53d8\u91cf\uff1a<code> int a;<\/code> \u6307\u9488\u548c\u8fd9\u79cd\u5b9a\u4e49\u5f88\u76f8\u4f3c\uff0c\u5982\u679c\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u6307\u9488p\u5e94\u8be5\u5982\u4f55\u53bb\u5199\u5462\uff1f\u6211\u4eec\u5728\u6b64\u4f7f\u7528\u4e86\u201c<code>*<\/code>\u201d\u7b26\u53f7\uff0c\u4e8e\u662f\u6307\u9488\u7684\u683c\u5f0f\u5c31\u662f<code>int *p;<\/code>\u5f53\u7136\uff0c\u6211\u4eec\u5728\u5b9a\u4e49\u7684\u65f6\u5019\u901a\u5e38\u4e0d\u4f1a\u5355\u72ec\u5b9a\u4e49\u3002\u6211\u4eec\u524d\u6587\u8bf4\u8fc7\uff0c\u6307\u9488\u4e2d\u5b58\u653e\u7684\u662f\u4e00\u4e2a\u5730\u5740\uff0c\u5728\u6ca1\u6709\u521d\u59cb\u5316\u7684\u60c5\u51b5\u4e0b\u901a\u5e38\u4f1a\u968f\u673a\u6307\u5411\u4e00\u4e2a\u5730\u5740\uff0c\u8fd9\u79f0\u4e4b\u4e3a<strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u91ce\u6307\u9488<\/mark><\/strong>\uff08\u4e5f\u88ab\u6210\u4e3a<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u60ac\u6302\u6307\u9488<\/mark>\uff09\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u91ce\u6307\u9488\u662f\u4e00\u4e2a\u975e\u5e38\u5371\u9669\u7684\u64cd\u4f5c\uff0c\u5982\u679c\u5176\u4e0d\u614e\u6307\u5411\u4e86\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u4e00\u4e2a\u91cd\u8981\u7684\u503c\uff0c\u800c\u6211\u4eec\u53c8\u4e0d\u614e\u66f4\u6539\uff0c\u5219\u53ef\u80fd\u5bfc\u81f4\u7535\u8111\u7cfb\u7edf\u5d29\u6e83\uff08\u5f53\u7136\u73b0\u5728\u7684\u64cd\u4f5c\u7cfb\u7edf\u901a\u5e38\u4e0d\u4f1a\u8ba9\u4f60\u8fd9\u6837\u505a\uff09\uff0c\u6240\u4ee5\u6211\u4eec\u901a\u5e38\u4f1a\u91c7\u7528\u8fd9\u79cd\u5b9a\u4e49\u65b9\u5f0f<code>int *p = NULL;<\/code>\u8ba9\u6307\u9488p\u7f6e\u7a7a\u5c31\u80fd\u907f\u514d\u51fa\u73b0\u91ce\u6307\u9488\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6307\u9488\u7684*\u662f\u8ddf\u968f\u7740\u53d8\u91cf\u540d\u800c\u975e\u7c7b\u578b\u540d\uff0c\u6307\u9488\u7684\u5927\u5c0f\u662f\u56fa\u5b9a\u7684\uff0c\u53ea\u4e0e\u8ba1\u7b97\u673a\u672c\u8eab\u6709\u5173\uff0c\u5982\u679c\u662f32\u4f4d\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5219\u6307\u9488\u4f4d4\u4e2a\u5b57\u8282\uff0c\u5982\u679c\u662f64\u4f4d\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5219\u6307\u9488\u4e3a8\u4e2a\u5b57\u8282\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6307\u9488\u5b9a\u4e49\u7684\u5f62\u5f0f\u4e5f\u662f <code>\u5b58\u50a8\u7c7b\u578b \u53d8\u91cf\u7c7b\u578b \u6307\u9488\u540d<\/code> \uff0c\u901a\u5e38\u5728\u7279\u522b\u58f0\u660e\u7684\u60c5\u51b5\u5916\uff0c\u4e5f\u5f80\u5f80\u6ca1\u6709\u5199\u5b58\u50a8\u7c7b\u578b\uff0c\u800c\u7531\u7f16\u8bd1\u5668\u81ea\u52a8\u8865\u5145\uff0c\u901a\u5e38\u5728\u51fd\u6570\u5185\u90e8\u4f1a\u9ed8\u8ba4\u4e3a<code>auto<\/code>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u8fc7\u8981\u6ce8\u610f\u7684\u4e00\u70b9\u662f\uff0c\u91ce\u6307\u9488\u4e0d\u4ec5\u4ec5\u4f1a\u5728\u521d\u59cb\u5316\u7684\u65f6\u5019\u53ef\u80fd\u51fa\u73b0\uff0c\u5728\u7a0b\u5e8f\u8fd0\u884c\u7684\u8fc7\u7a0b\u4e2d\u4e5f\u53ef\u80fd\u4f1a\u51fa\u73b0\uff0c\u6bd4\u5982\uff1a\u6307\u9488\u6307\u5411\u7684\u5bf9\u8c61\u6d88\u4ea1\u4f46\u662f\u6307\u9488\u4f9d\u65e7\u6307\u5411\u8be5\u5730\u5740\u6216\u8005\u662f\u6307\u9488\u91ca\u653e\uff08<code>free\u3001delete<\/code>\uff09\u540e\u6ca1\u6709\u7f6e\u7a7a\u3002\u4e0d\u8fc7\u8fd9\u5c5e\u4e8e\u77e5\u8bc6\u70b9\u5f88\u9760\u540e\u7684\u5185\u5bb9\uff0c\u672c\u6587\u7684\u6b63\u6587\u6682\u65f6\u4e0d\u6d89\u53ca\uff0c\u5982\u679c\u611f\u5174\u8da3\u53ef\u4ee5\u770b\u4e00\u770b\u672c\u6587\u672b\u5c3e\u7684\u201c\u8865\u5145\u201d\u677f\u5757\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6240\u4ee5\u6211\u4eec\u5728\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\u5e94\u8be5\u65f6\u523b\u6ce8\u610f\u6307\u9488\u6240\u6307\u5411\u7684\u5730\u5740\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u56de\u5230\u6b63\u9898\uff0c\u8bb2\u5b8c\u4e86\u5982\u4f55\u521b\u5efa\u6307\u9488\uff0c\u6211\u4eec\u518d\u770b\u770b\u5982\u4f55\u7ed9\u6307\u9488\u8d4b\u503c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a\u65f6\u5019\u6211\u4eec\u5f15\u5165\u4e86<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u53d6\u5730\u5740<\/mark>\u7b26\u53f7\u201c<code>&amp;<\/code>\u201d\uff0c\u5047\u8bbe\u4e00\u4e2a\u53d8\u91cf<code>int a = 1;<\/code> \u90a3\u4e48\u8981\u53d6a\u7684\u5730\u5740\u64cd\u4f5c\u5c31\u662f&amp;a;\u6211\u4eec\u5728\u7ed9\u6307\u9488\u8d4b\u503c\u7684\u65f6\u5019\u5c31\u4f1a\u4f7f\u7528\u5982\u4e0b\u64cd\u4f5c <code>int *p = &amp;a;<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u8fc7\u6211\u4eec\u4e5f\u4e0d\u4e00\u5b9a\u975e\u8981\u5728\u5b9a\u4e49\u7684\u65f6\u5019\u8d4b\u521d\u503c\uff0c\u4ee5\u4e0b\u64cd\u4f5c\u4e5f\u662f\u53ef\u4ee5\u7684\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int a = 1;\nint *p = NULL;\np = &amp;a;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u540c\u6837\uff0c\u6307\u9488\u548c\u666e\u901a\u7684\u53d8\u91cf\u5f88\u76f8\u4f3c\uff0c\u53ea\u4e0d\u8fc7\u6307\u9488\u5b58\u653e\u7684\u662f\u5730\u5740\uff0c\u6240\u4ee5\u5982\u4e0b\u64cd\u4f5c\u4e5f\u662f\u53ef\u4ee5\u7684\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int a = 1;\nint *p1 = NULL;\nint *p2 = NULL;\np1 = &amp;a;\np2 = p1;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0cp1\u7684\u503c\u8d4b\u7ed9\u4e86p2\uff1b\u6240\u4ee5\u6307\u9488p1\u548cp2\u90fd\u662f\u5b58\u653e\u7684\u53d8\u91cfa\u7684\u5730\u5740\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6307\u9488\u7684\u89e3\u5f15\u7528\u64cd\u4f5c<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bb2\u5b8c\u4e86\u5982\u4f55\u5b9a\u4e49\u6307\u9488\uff0c\u5f88\u5bb9\u6613\u5c31\u80fd\u8054\u60f3\u5230\u5982\u4f55\u8bbf\u95ee\u8fd9\u4e2a\u5730\u5740\u7684\u503c\uff0c\u8fd9\u4e2a\u65f6\u5019\u6211\u4eec\u4f7f\u7528\u7684\u4f9d\u65e7\u662f&#8221;<code>*<\/code>&#8220;\uff0c\u4e0d\u8fc7\u6b64\u65f6\u5b83\u7684\u542b\u4e49\u5df2\u7ecf\u6539\u53d8\u4e86\uff0c\u53ea\u6709\u5728\u5b9a\u4e49\u7684\u65f6\u5019\u624d\u662f\u6307\u9488\u7b26\u53f7\uff0c\u8fd9\u4e2a\u65f6\u5019\u5b83\u7684\u64cd\u4f5c\u53eb\u505a\u201c<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u89e3\u5f15\u7528<\/mark>\u201d\u3002\u8bf7\u8ba9\u6211\u4eec\u770b\u4e00\u4e0b\u4ee5\u4e0b\u7684\u4f8b\u5b50\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\nint main()\n{\n    int a = 1;\n    int *p = &amp;a;\n\n    printf(\"a = %d\\n\",a);\n    printf(\"*p = %d\\n\",*p);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u8fd0\u884c\u7ed3\u679c<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">a = 1<br>*p = 1<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5bf9\u6307\u9488p\u8fdb\u884c\u89e3\u5f15\u7528\u64cd\u4f5c\u540e\u5f97\u5230\u4e86\u7684\u503c\u5c31\u662fa\u7684\u503c\uff0c\u90a3\u4e48\u5982\u679c\u4e0d\u5bf9a\u89e3\u5f15\u7528\uff0cp\u672c\u8eab\u5b58\u653e\u7684\u503c\u662f\u4ec0\u4e48\u5462\uff1f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\nint main()\n{\n    int a = 1;\n    int *p = &amp;a;\n    printf(\"&amp;a = %p\\n\",&amp;a);\n    printf(\"p = %p\\n\",p);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u8fd0\u884c\u7ed3\u679c<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">&amp;a = 0x7fffaf406e64<br>p = 0x7fffaf406e64<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u53ef\u4ee5\u6e05\u695a\u7684\u770b\u5230\uff0cp\u672c\u8eab\u5b58\u653e\u7684\u662f\u4e00\u4e32\u5730\u5740\uff0c\u800c\u8fd9\u4e32\u5730\u5740\u548c\u5c31\u662fa\u7684\u5730\u5740\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u770b\u5230\u4e86\u8fd9\u91cc\uff0c\u8bfb\u8005\u6216\u8bb8\u5fc3\u4e2d\u6709\u7591\u60d1\uff0c\u6211\u660e\u660e\u53ef\u4ee5\u7528a\u6765\u83b7\u53d6\u503c\uff0c\u4e3a\u4ec0\u4e48\u8fd8\u8981\u591a\u6b64\u4e00\u4e3e\u5f15\u5165\u6307\u9488\u8fd9\u4e2a\u6982\u5ff5\uff0c\u5176\u5b9e\u5f88\u591a\u4eba\u5728\u521d\u6b21\u63a5\u89e6\u7684\u65f6\u5019\u90fd\u4f1a\u5b58\u5728\u8fd9\u6837\u7684\u7591\u95ee\uff0c\u4e0d\u8fc7\u5f88\u591a\u76f8\u5173\u7684\u6587\u7ae0\u5e76\u6ca1\u6709\u5f88\u597d\u7684\u8bb2\u89e3\u8fc7\uff0c\u4f46\u6211\u6ca1\u6709\u7559\u60ac\u5ff5\u7684\u4e60\u60ef\uff0c\u63a5\u4e0b\u6765\u6211\u4e3a\u5927\u5bb6\u4e3e\u4e00\u4e2a\u4f8b\u5b50\u65b9\u4fbf\u5927\u5bb6\u7406\u89e3\u6307\u9488\u7684\u91cd\u8981\u6027\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\nvoid swap(int a,int b){\/\/\u8fd9\u91cc\u521b\u5efa\u4e00\u4e2a\u503c\uff0c\u4f5c\u7528\u662f\u5c06a\u548cb\u7684\u503c\u4ea4\u6362\n    int temp;\n    temp = a;\n    a = b;\n    b = temp;\n}\nint main()\n{\n    int a = 1;\n    int b = 2;\n    swap(a,b);\/\/\u4ea4\u6362a\u548cb\u7684\u503c\n    printf(\"a = %d\\n\",a);\n    printf(\"b = %d\\n\",b);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bfb\u8005\u8bf7\u770b\u4e00\u4e0b\u8fd9\u4e2a\u4f8b\u5b50\uff0c\u53ef\u4ee5\u5206\u6790\u4e00\u4e0b\u8f93\u51fa\u7ed3\u679c\u662f\u4ec0\u4e48\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u8fd0\u884c\u7ed3\u679c<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">a = 1<br>b = 2<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b83\u7684\u8f93\u51fa\u7ed3\u679c\uff0c\u548c\u6211\u4eec\u7684\u9884\u671f\u5b8c\u5168\u76f8\u53cd\uff0c\u5e76\u6ca1\u6709\u8fdb\u884c\u4ea4\u6362\u3002\u5176\u539f\u56e0\u5c31\u662f\u2014\u2014swap(int a,int b)\u4e2d\u4f20\u5165\u7684\u53c2\u6570\u5176\u5b9e\u662fmain\u51fd\u6570\u4e2d\u4e24\u4e2a\u53d8\u91cf\u7684\u526f\u672c\uff0c\u6b64a\u975e\u5f7ca\uff0c\u6b64b\u975e\u5f7cb\uff0c\u5c31\u50cf1\u73ed\u4e0a\u548c\u9694\u58c12\u73ed\u90fd\u6709\u4e00\u4e2a\u540d\u5b57\u53eb\u505a\u5f20\u4e09\u7684\u540c\u5b66\uff0c\u4f46\u540d\u5b57\u4e00\u6837\u5374\u4e0d\u662f\u4e00\u4e2a\u4eba\u3002\u540c\u7406\uff0cswap\u91cc\u9762\u7684a\u548cmain\u91cc\u9762\u7684a\u867d\u7136\u90fd\u662fa\uff0c\u5e76\u4e14\u503c\u90fd\u662f1\uff0c\u4f46\u662f\u5374\u4e0d\u662f\u4e00\u4e2aa\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u8054\u60f3\u4e00\u4e0b\u6211\u60f3\u627e1\u73ed\u7684\u5f20\u4e09\u8be5\u600e\u4e48\u505a\uff0c\u6211\u4eec\u4f1a\u627e\u5230\u4e00\u73ed\u6240\u5728\u7684\u73ed\u7ea7\uff0c\u518d\u627e\u5230\u90a3\u4e2a\u53eb\u5f20\u4e09\u7684\u4eba\u3002\u4e5f\u5c31\u662f\u6211\u4eec\u786e\u5b9a\u4e86\u5730\u5740\u662f1\u73ed\u3002\u90a3\u4e48\u63a5\u4e0b\u6765\u6211\u4eec\u770b\u4e00\u4e0b\u4e0b\u9762\u66f4\u65b0\u540e\u7684\u4ee3\u7801\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\nvoid swap(int *pa,int *pb){\/\/\u6211\u4eec\u5c06main\u4e2da\u548cb\u7684\u5730\u5740\u4f20\u8fc7\u6765\u3002\n    int temp;\n    temp = *pa;\/\/ \u6211\u4eec\u5df2\u7ecf\u8bb2\u8fc7*\u5728\u6b64\u65f6\u5df2\u7ecf\u662f\u89e3\u5f15\u7528\u64cd\u4f5c\uff0c\u6240\u4ee5\uff0c*pa\u5176\u5b9e\u5c31\u76f8\u5f53 main\u4e2d\u7684a\n    *pa = *pb;\n    *pb = temp;\/\/\u5c06pa\u548cpb\u4e2d\u5b58\u653e\u7684\u5730\u5740\u6240\u5bf9\u5e94\u7684\u503c\u8fdb\u884c\u4e86\u4ea4\u6362\n}\nint main()\n{\n    int a = 1;\n    int b = 2;\n    swap(&amp;a,&amp;b);\/\/\u5c06a\u548cb\u7684\u5730\u5740\u4f20\u5165\u51fd\u6570\n    printf(\"a = %d\\n\",a);\n    printf(\"b = %d\\n\",b);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u8fd0\u884c\u7ed3\u679c<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">a = 2<br>b = 1<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u770b\uff0c\u6211\u4eec\u901a\u8fc7\u6307\u9488\u7684\u65b9\u5f0f\u6210\u529f\u5c06\u4e24\u4e2a\u503c\u8fdb\u884c\u4e86\u4ea4\u6362\uff0c\u770b\u5230\u8fd9\u91cc\uff0c\u5e94\u8be5\u80fd\u611f\u5230\u6307\u9488\u7684\u4f5c\u7528\u4e86\u5427<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u8fc7\u8fd8\u6709\u4e00\u4e2a\u6ce8\u610f\u7684\u4e00\u70b9\uff0c\u5b9a\u4e49\u6307\u9488\u5fc5\u987b\u8981\u548c\u4f60\u60f3\u6307\u5411\u7684\u53d8\u91cf\u76f8\u5bf9\u5e94\uff0c\u6bd4\u5982<code>int *<\/code>\u5bf9\u5e94\u7684\u662f<code>int <\/code>\uff0c\u4f60\u4e0d\u80fd\u7528<code>int *<\/code>\u7684\u6307\u9488\u53bb\u5f15\u7528\u4e00\u4e2a<code>char<\/code>\u7c7b\u578b\u7684\u53d8\u91cf<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6307\u9488\u7684\u8fd0\u7b97<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bf4\u5230\u6307\u9488\u7684\u8fd0\u7b97\uff0c\u5c31\u6709\u4e00\u4e2a\u4e0d\u5f97\u4e0d\u63d0\u7684\u91cd\u8981\u6982\u5ff5\u2014\u2014<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u6307\u9488\u7684\u6b65\u957f<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6307\u9488\u7684\u6b65\u957f\u7b80\u5355\u6765\u8bf4\u5c31\u662f\u6307\u9488\u79fb\u52a8\u6240\u8de8\u8d8a\u7684\u957f\u5ea6\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u5148\u6765\u8bb2\u4e00\u4e0b\u6307\u9488\u7684\u56db\u5219\u8fd0\u7b97\u2014\u2014\u5355\u76ee\u8fd0\u7b97++\u3001&#8211;\u53cc\u76ee\u8fd0\u7b97+\u3001-<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5185\u5b58\u4e2d\u7684\u5730\u5740\u662f\u8fde\u7eed\u7684\uff0c\u5982\u679c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\u53d8\u91cf <code>int a;<\/code>\u90a3\u4e48\u5b83\u4f1a\u5728\u5185\u5b58\u4e2d\u5f00\u8f9f\u4e00\u4e2a\u56db\u4e2a\u5b57\u8282\u7684\u7a7a\u95f4\uff0c\u6bd4\u5982<code>0x00<\/code>\uff0c\u867d\u7136\u5b83\u7684\u5730\u5740\u662f<code>0x00<\/code>\uff0c\u4f46\u662f\u672c\u8d28\u4e0a\u5b83\u5360\u7528\u4e86<code>0x00~0x03<\/code>\u5408\u8ba1\u957f\u5ea6\u4e3a\u56db\uff0c\u6240\u4ee5\u4ece<code>0x01<\/code>\u5230<code>0x03<\/code>\u4e2d\uff0c\u5176\u4ed6\u6570\u636e\u662f\u65e0\u6cd5\u5360\u7528\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u90a3\u4e48\u6211\u4eec\u518d\u6765\u770b\u6307\u9488\uff0c\u5047\u8bbe\u6709\u4e24\u4e2a\u8fde\u7eed\u7684\u53d8\u91cf<code>int a<\/code>\u548c<code>int b<\/code>\uff1b\u5b83\u4eec\u7684\u5730\u5740\u5206\u522b\u662f<code>0x00,0x04<\/code>\uff1b\u90a3\u4e48\u6307\u9488\u7684\u79fb\u52a8\u5c31\u662f\u6309\u7167\u6574\u4e2a\u6570\u636e\u7684\u957f\u5ea6\u79fb\u52a8\uff0c\u5982<code>int *p = &amp;a; <\/code>\u90a3\u4e48<code>p++<\/code>\u4e4b\u540e\uff0cp\u4e2d\u5b58\u653e\u7684\u5730\u5740\u5c31\u53d8\u6210\u4e86<code>0x04<\/code>\u4e86\uff0c\u8fd9\u4e2a\u79fb\u52a8\u7684\u957f\u5ea6\u5c31\u662f\u6307\u9488\u7684<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u6b65\u957f<\/mark>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6307\u9488\u7684\u6b65\u957f\u5c31\u662f\u6309\u7167\u6307\u9488\u6240\u6307\u7684\u6570\u636e\u7c7b\u578b\u7684\u957f\u5ea6\u6765\u7b97\u7684\uff0c\u4f8b\u5982<code>char *pc,<\/code>\u90a3\u4e48\u6307\u9488<code>pc<\/code>\u7684\u6b65\u957f\u5c31\u662f<code>char<\/code>\u8fd9\u4e2a\u6570\u636e\u7c7b\u578b\u5360\u7528\u7a7a\u95f4\u7684\u5927\u5c0f\uff0c\u4e5f\u5c31\u662f\u4e00\u4e2a\u5b57\u8282\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bf4\u660e\u767d\u4e86\u6b65\u957f\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5f00\u59cb\u6b63\u5f0f\u5b66\u4e60\u56db\u5219\u8fd0\u7b97\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>++ \uff1a\u8fd9\u4e2a\u5f88\u597d\u7406\u89e3\uff0c\u548c\u6211\u4eec\u7684\u53d8\u91cf\u4e00\u6837\uff0c\u6bd4\u5982<code>int a = 0\uff1ba++<\/code>\u4e4b\u540e\u7684\u503c\u5c31\u662f1\uff0c\u4f46\u6307\u9488\u4e0d\u4e00\u6837\uff0c\u6211\u4eec\u5b66\u4e60\u4e86\u6b65\u957f\u7684\u6982\u5ff5\uff0c\u6307\u9488\u7684\u79fb\u52a8\u662f\u6309\u7167\u6b65\u957f\u6765\u7b97\u7684\uff0c\u5982\u679c<code>p = &amp;a<\/code>\uff1b\u90a3\u4e48<code>p++<\/code>\u540e\u5c31\u8df3\u5230\u4e864\u4e2a\u5b57\u8282\u540e\u7684\u5730\u5740\u3002\u4e5f\u5c31\u662f\u5f80\u540e\u632a\u4e00\u4e2a\u6b65\u957f\u7684\u957f\u5ea6\u3002<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&#8211; &#8211; \uff1a\u548c++\u7c7b\u4f3c\uff0c\u4e0d\u8fc7\u5b83\u76f8\u53cd\uff0c\u4ed6\u662f\u5f80\u524d\u632a\u4e00\u4e2a\u6b65\u957f\u7684\u957f\u5ea6\uff0c\u5982\u679c\u539f\u5730\u5740\u662f<code>0x04<\/code>\uff1b\u90a3\u4e48- -\u540e\u5c31\u662f<code>0x00<\/code><\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>+ \uff1a\u548c\u524d\u9762\u4e5f\u662f\u5f02\u66f2\u540c\u5de5\uff0c\u6bd4\u5982<code>int a = 0; int *p =&amp;a<\/code>;\u5982\u679ca\u7684\u5730\u5740\u662f<code>0x00<\/code>\uff0c\u90a3\u4e48<code>p+10<\/code>\u5c31\u662fp\u5f80\u540e\u632a\u4e8610\u4e2a\u6b65\u957f\u7684\u957f\u5ea6\uff0c\u90a3\u4e48\u5b83\u7684\u5730\u5740\u5c31\u662f<code>0x40<\/code><\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&#8211; : \u540c\u4e0a\uff0c\u524d\u63d0\u4e5f\u662fint\u7c7b\u578b\uff0c\u5982\u679cp\u539f\u5730\u5740\u662f<code>0x40<\/code>\u90a3\u4e48<code>p-10<\/code>\u5c31\u662f\u5f80\u524d\u632a10\u4e2a\u6b65\u957f\u7684\u957f\u5ea6\uff0c\u65b0\u5730\u5740\u4e5f\u5c31\u662f<code>0x00<\/code><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u591a\u7ea7\u6307\u9488<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u524d\u9762\u8bf4\u8fc7\uff0c\u4e00\u4e2a\u53d8\u91cf\u662f\u6709\u4e24\u4e2a\u610f\u4e49\uff0c\u4e00\u4e2a\u5730\u5740\uff0c\u4e00\u4e2a\u6570\u503c\u3002\u6307\u9488\u4e5f\u4e0d\u4f8b\u5916\uff0c\u5b83\u867d\u7136\u503c\u662f\u5b58\u653e\u7684\u6307\u9488\uff0c\u4f46\u662f\u5b83\u81ea\u8eab\u4e5f\u5b58\u5728\u5730\u5740\uff0c\u65e2\u7136\u5b58\u5728\u5730\u5740\uff0c\u90a3\u5c31\u4e0d\u96be\u6709\u4e00\u4e2a\u731c\u60f3\u2014\u2014\u662f\u5426\u80fd\u7528\u6307\u9488\u5b58\u653e\u6307\u9488\u7684\u5730\u5740\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b54\u6848\u662f\u80af\u5b9a\u7684\uff0c\u8fd9\u5c31\u662f\u6211\u4eec\u63a5\u4e0b\u6765\u8981\u8bf4\u7684\u591a\u7ea7\u6307\u9488<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5148\u6765\u8bf4\u4e00\u8bf4\u5b9a\u4e49<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\nint main()\n{\n    int a = 1;\/\/\u53d8\u91cf\n    int *p = &amp;a;\/\/\u4e00\u7ea7\u6307\u9488\n    int **p2 = &amp;p;\/\/\u4e8c\u7ea7\u6307\u9488\n\n    printf(\"a = %d\\n\",a);\/\/\n    printf(\"*p = %d\\n\",*p);\/\/\n    printf(\"**p2 = %d\\n\",**p2);\/\/\n\n    printf(\"&amp;a = %p\\n\",&amp;a);\/\/a\u7684\u5730\u5740\n    printf(\"p = %p\\n\",p);\/\/p\u4e2d\u5b58\u653e\u7684\u6570\u636e\n    printf(\"&amp;p = %p\\n\",&amp;p);\/\/p\u672c\u8eab\u7684\u5730\u5740\n    printf(\"p2 = %p\\n\",p2);\/\/p2\u4e2d\u5b58\u653e\u7684\u6570\u636e\n\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u8fd0\u884c\u7ed3\u679c<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">a = 1<br>*p = 1<br>**p2 = 1<br>&amp;a = 0x7ffe1d09e3b4<br>p = 0x7ffe1d09e3b4<br>&amp;p = 0x7ffe1d09e3a8<br>p2 = 0x7ffe1d09e3a8<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u4ece\u4ee3\u7801\u4e0a\u53ef\u4ee5\u770b\u5230\uff0c\u4e8c\u7ea7\u6307\u9488\u4f7f\u7528\u4e86\u4e24\u4e2a<code>*<\/code>\u53f7\uff0c\u8fd9\u5c31\u662f\u591a\u7ea7\u6307\u9488\u7684\u8868\u793a\u65b9\u5f0f\uff0c\u51e0\u7ea7\u6307\u9488\u5c31\u7528\u51e0\u4e2a*\u53f7\uff0c\u540c\u6837\u5728\u89e3\u5f15\u7528\u7684\u65f6\u5019\u4e5f\u4e00\u6837\u3002\u63a5\u4e0b\u6765\u6211\u5206\u6790\u4e00\u4e0b\u5b9a\u4e49\u8fc7\u7a0b\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\u6211\u4eec\u770b\u5230p2\uff0c\u6211\u4eec\u53ef\u4ee5\u628a\u5b83\u5f53\u505a\u4e00\u4e2a\u4e00\u7ea7\u6307\u9488\uff0c\u53ea\u4e0d\u8fc7p\u662f\u4e00\u4e2a\u5b58\u653e\u5730\u5740\u7684\u53d8\u91cf\uff0c\u8fd9\u6837\u518d\u770b\u662f\u4e0d\u662f\u5c31\u6e05\u6670\u4e86\u5f88\u591a\uff0c\u540c\u6837\u7684\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u5f15\u51faint <code>***p3 =&amp;p2;<\/code>\u4e00\u6837\u7684\u906e\u4f4f\u4e24\u4e2a<code>*<\/code>\u53f7\uff0c\u5c31\u53ef\u4ee5\u770b\u6210<code> int *p3=&amp;p2<\/code>\u53ea\u4e0d\u8fc7p2\u662f\u4e00\u4e2a\u5b58\u653e\u5730\u5740\u7684\u53d8\u91cf\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u5b9e\u4ece\u53e6\u4e00\u4e2a\u89d2\u5ea6\u4e5f\u53ef\u4ee5\u7406\u89e3\uff0c\u6211\u4eec\u5206\u5f00\u6765\u770b\uff0c<code>int**   *p3 = &amp;p2<\/code>\uff0c\u5c31\u53ef\u4ee5\u7406\u89e3\u6210\u5b9a\u4e49\u4e86\u4e00\u4e2a\u6307\u9488p3\uff0c\u8fd9\u4e2a\u6307\u9488\u6307\u5411\u7684\u7c7b\u578b\u662f<code>int**<\/code>\uff0c\u800c\u6211\u4eec\u518d\u770b\u770b p2\u7684\u5b9a\u4e49\uff0c\u540c\u7406<code> int* *p2<\/code>\u5b9a\u4e49\u4e86\u4e00\u4e2a\u6307\u9488p2\uff0c\u8fd9\u4e2a\u6307\u9488\u6307\u5411\u7684\u7c7b\u578b\u662f<code>int*<\/code>,\u6700\u540e\u770b\u4e00\u4e0b<code>int *p<\/code>\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\u6307\u9488p\uff0c\u8fd9\u4e2a\u6307\u9488\u6307\u5411\u7684\u7c7b\u578b\u662f<code>int<\/code>\uff0c\u8fd9\u4e00\u4e2a\u79cd\u5206\u6790\u65b9\u6cd5\u4e0d\u4ec5\u5c06\u591a\u7ea7\u6307\u9488\u8054\u7cfb\u4e86\u8d77\u6765\uff0c\u5c31\u8fde\u6307\u9488\u548c\u666e\u901a\u53d8\u91cf\u4e5f\u8054\u7cfb\u4e86\u8d77\u6765\uff0c\u4e24\u79cd\u65b9\u6cd5\u8bfb\u8005\u90fd\u53ef\u4ee5\u8bd5\u4e00\u8bd5\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u518d\u6765\u770b\u770b\u89e3\u5f15\u7528\uff0c\u540c\u6837\u4f7f\u7528\u7684\u662f*\u53f7\uff0c\u4e0d\u8fc7\u7406\u89e3\u8fc7\u7a0b\u8981\u7a0d\u5fae\u6709\u70b9\u4e0d\u540c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u6765\u770b\u4e00\u770bp2\uff0c\u5b83\u7684\u89e3\u5f15\u7528\u4f7f\u7528\u4e86**p2\uff0c\u6211\u4eec\u6cbf\u7740\u8868\u8fbe\u5f0f\u9010\u6b65\u5206\u6790\u4e00\u4e0b\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\uff0c\u6211\u4eec\u5728\u524d\u6587\u5df2\u7ecf\u5b66\u4e60\u8fc7<code>*p<\/code>\u80fd\u89e3\u5f15\u7528\u51fap\u6307\u5411\u7684\u5730\u5740\u4e2d\u7684\u503c\u3002\u90a3\u6211\u4eec\u5c06\u76ee\u5149\u770b\u5230<code>**p2<\/code>\uff0c\u7136\u540e\u6211\u4eec\u5c06<code>*p2<\/code>\u5355\u72ec\u62ce\u51fa\u6765\uff0c\u5c31\u5f97\u5230\u4e86<code>* \uff08*p2\uff09<\/code>\uff0c\u8fd9\u6837\u5c31\u5b9e\u73b0\u4e86\u903b\u8f91\u4e0a\u7684\u964d\u7ea7\uff0c\u6309\u7167\u6211\u4eec\u521a\u521a\u7684\u60f3\u6cd5\uff0c<code>*p2<\/code>\u89e3\u5f15\u7528\u540e\u5c31\u5f97\u5230\u4e86p\u4e2d\u5b58\u653e\u7684\u503c\uff0c\u5c31\u662fa\u7684\u5730\u5740\uff0c\u7136\u540e\u6211\u4eec\u5c06\u5916\u9762\u7684*\u548c\u88ab\u89e3\u5f15\u7528\u540e\u7684\u503c\u7ed3\u5408\u8d77\u6765\uff0c\u5c31\u76f8\u5f53\u4e8e\u5bf9p\u8fdb\u884c\u4e86\u89e3\u5f15\u7528\uff0c\u4ece\u800c\u5f97\u5230a\u7684\u503c\uff1a<code>**p2-&gt; * (*p2) -&gt;*p -&gt;a<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u603b\u7ed3\u4e00\u4e0b\uff0c<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u5b9a\u4e49\u91c7\u7528\u7684\u662f\u9694\u79bb\u601d\u60f3\uff0c\u5c06\u6bcf\u4e00\u4e2a\u6570\u636e\u7c7b\u578b\u4e00\u4e2a\u4e2a\u5265\u79bb\uff0c\u89e3\u5f15\u7528\u91c7\u7528\u964d\u7ea7\u601d\u60f3\uff0c\u4e00\u6b65\u6b65\u964d\u4f4e\u6307\u9488\u7ea7\u6570<\/mark><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">void*\u578b\u6307\u9488<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">void*\u578b\u6307\u9488\u662f\u4e00\u4e2a\u7279\u6b8a\u7684\u6307\u9488\u7c7b\u578b\uff0c\u5b83\u7684\u7279\u70b9\u662f\u53ef\u4ee5\u627f\u63a5\u4efb\u4f55\u6307\u9488\uff0c\u4f46\u662f\u4e0d\u80fd\u88ab\u89e3\u5f15\u7528\uff0c\u4e0d\u8fc7\u8fd9\u4e5f\u597d\u7406\u89e3\uff0c\u56e0\u4e3a\u8fd9\u662f\u4e00\u4e2a\u7a7a\u7c7b\u578b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;stdio.h&gt;\nint main(){\n    int a = 10;\n    int *p = &amp;a;\n    void *pv = p;\n    int *p2 = pv;\n    printf(\"a = %d\\n\",*p2);\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u8fd0\u884c\u7ed3\u679c<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">a = 10<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u901a\u8fc7\u8fd9\u4e2a\u4f8b\u5b50\u53ef\u4ee5\u770b\u5230\uff0cpv\u53ef\u4ee5\u88abint*\u7684\u6307\u9488\u4f20\u5740\uff0c\u5e76\u4f20\u7ed9p2\uff0c\u8fd9\u4e5f\u662fvoid*\u578b\u6307\u9488\u7684\u4e3b\u8981\u7528\u6cd5\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u7136\u8fd9\u4e2avoid*\u6307\u9488\u4e00\u822c\u4e5f\u4e0d\u4f1a\u8fd9\u6837\u4f7f\u7528\uff0c\u901a\u5e38\u8fd9\u4e2a\u4f20\u9012\u662f\u7528\u5728\u51fd\u6570\u7684\u8fd4\u56de\u503c\u4e2d\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6307\u9488\u5e38\u91cf\u548c\u5e38\u91cf\u6307\u9488<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u524d\u6587\u6211\u4eec\u5df2\u7ecf\u521d\u6b65\u4e86\u89e3\u4e86\u6307\u9488\uff0c\u73b0\u5728\u6211\u4eec\u5f00\u59cb\u8be6\u7ec6\u4ecb\u7ecd\u6307\u9488\u548c\u5404\u79cd\u6982\u5ff5\u7684\u7ed3\u5408\uff0c\u53ef\u80fd\u521d\u6b21\u7406\u89e3\u6709\u4e9b\u56f0\u96be\uff0c\u4e0d\u8fc7\u591a\u770b\u51e0\u6b21\u5c31\u80fd\u7406\u89e3\u4e86\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u5728\u770b\u5230\u6807\u9898\u8fd9\u4e00\u7c7b\u7684\u540d\u8bcd\u65f6\u8981\u628a\u63e1\u4e00\u4e2a\u70b9\uff0c\u53ea\u770b\u6700\u540e\u4e00\u4e2a\u540d\u8bcd\uff0c\u524d\u9762\u7684\u90fd\u4e0d\u8981\u770b\uff0c\u7136\u540e\u8fd9\u4e2a\u6807\u9898\u5c31\u53d8\u6210\u4e86\u201c\u5e38\u91cf\u548c\u6307\u9488\u201d<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6240\u4ee5\u6211\u4eec\u77e5\u9053\u4e86\u6307\u9488\u5e38\u91cf\u5c31\u662f\u4e00\u4e2a\u6307\u9488\u7684\u5e38\u91cf\uff0c\u672c\u8d28\u662f\u4e00\u4e2a\u5e38\u91cf\uff0c\u5e38\u91cf\u6307\u9488\u662f\u4e00\u4e2a\u6307\u5411\u5e38\u91cf\u7684\u6307\u9488\uff0c\u672c\u8d28\u662f\u6307\u9488\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u5148\u6765\u770b\u4e00\u4e0b\u4e24\u8005\u7684\u5b9a\u4e49\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\nint main()\n{\n    const int a = 1;\/\/\u5e38\u91cf  line1\n    int b = 2;\/\/\u53d8\u91cf      line2\n\n    const int *pa = &amp;a;\/\/\u5e38\u91cf\u6307\u9488    line3\n    int *const pb = &amp;b;\/\/\u6307\u9488\u5e38\u91cf    line4\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6587\u5b57\u5b9a\u4e49\u5f88\u7ed5\uff0c\u5982\u679c\u76f4\u63a5\u6362\u6210\u4ee3\u7801\u8fd9\u6837\u770b\u5c31\u6e05\u695a\u5f88\u591a\u4e86\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u5148\u770bline1,<code>const <\/code>\u662f\u4e00\u4e2a\u5e38\u91cf\u6807\u8bc6\u7b26\uff0c\u5e38\u91cf\u5c31\u662f\u5b9a\u4e86\u5c31\u65e0\u6cd5\u6539\u53d8\u7684\u91cf\uff0c\u6240\u4ee5\u8fd9\u4e2aa \u5c31\u53ea\u80fd\u7b49\u4e8e1 \u540e\u7eed\u5982\u679c\u5199\u4e00\u4e2a<code>a = 2\uff1b<\/code>\u8fd9\u6837\u7684\u8d4b\u503c\u4ee3\u7801\uff0c\u7f16\u8bd1\u5668\u4f1a\u629b\u51fa\u4e00\u4e2a\u9519\u8bef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u540e\u6211\u4eec\u518d\u770b\u4e00\u770bline3\uff0c\u6211\u4eec\u5206\u6790\u4e00\u4e0b\u5b83\u7684\u7c7b\u578b\u662f\u4ec0\u4e48\uff0c\u5148\u906e\u4f4fpa\uff0c\u76ee\u5149\u5f80\u524d\u79fb\u52a8\uff0c\u80fd\u770b\u5230<code>*<\/code>\uff0c\u6240\u4ee5\u6211\u4eec\u77e5\u9053\u4e86pa\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u90a3\u8fd9\u4e2a\u6307\u9488\u6307\u5411\u7684\u6570\u636e\u7c7b\u578b\u662f\u4ec0\u4e48\u5462\uff0c\u63a5\u7740\u5f80\u524d\u770b\uff0c\u662fint\u7c7b\u578b\uff0c\u6240\u4ee5\u6211\u4eec\u770b\u5230\u4e86pa\u662f\u4e00\u4e2a\u6307\u5411<code>int<\/code>\u7c7b\u578b\u7684\u6307\u9488\uff0c\u4f46\u8fd8\u6ca1\u5b8c\uff0c\u524d\u9762\u8fd8\u6709\u4e00\u4e2a<code>const<\/code>\uff0c\u539f\u6765\u8fd9\u4e2aint\u8fd8\u662f\u4e00\u4e2a\u5e38\u91cf\uff0c\u6700\u7ec8\u6211\u4eec\u5f97\u51fa\u6765\u4e00\u4e2a\u7ed3\u8bba\uff0c\u8fd9\u662f\u4e00\u4e2a\u6307\u9488pa\uff0c\u5b83\u6307\u5411\u7684\u662f\u4e00\u4e2a<code>const int<\/code>\u7c7b\u578b\u7684\u503c\uff0c\u4e5f\u5c31\u662f\u5e38\u91cf\u6307\u9488\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u518d\u6765\u770b\u4e00\u4e0bline2\uff0c\u8fd9\u662f\u4e00\u4e2a\u6574\u578b\u53d8\u91cfb\uff0c\u8fd9\u6ca1\u4ec0\u4e48\u597d\u8bb2\u7684\uff0c\u6211\u4eec\u5c06\u76ee\u5149\u79fb\u5230line4\uff0c\u8fd8\u662f\u4e00\u6837\u7684\u65b9\u6cd5\uff0c\u6211\u4eec\u906e\u4f4fpb\uff0c\u5269\u4e0b\u7684\u5c31\u662f\u4e00\u4e2a<code>int *const <\/code>\uff0c\u6211\u4eec\u5c31\u8fd1\u52a0\u4e0a\u4ece<code>const<\/code>\u770b\u4e00\u770b\uff0c\u5c31\u662f<code>const pb<\/code>\uff0c\u6240\u4ee5\u6211\u4eec\u5df2\u7ecf\u80fd\u770b\u5230pb\u88ab\u9650\u5236\u6210\u4e86\u4e00\u4e2a\u5e38\u91cf\u3002\u90a3\u8fd9\u662f\u4e00\u4e2a\u4ec0\u4e48\u7c7b\u578b\u7684\u5e38\u91cf\u5462\uff0c\u6211\u4eec\u63a5\u7740\u5f80\u524d\u9762\u770b\uff0c\u8fd9\u662f\u4e00\u4e2a*\u6307\u9488\u7b26\u53f7\uff0c\u6240\u4ee5\u6211\u4eec\u5df2\u7ecf\u80fd\u770b\u51fa\u6765\u4e86\uff0cpb\u662f\u4e00\u4e2a\u5e38\u91cf\u6307\u9488\uff0c\u8fd9\u4e2a\u6307\u9488\u5e38\u91cf\u6307\u7684\u662f\u4ec0\u4e48\u6570\u636e\u7c7b\u578b\u662f\u4ec0\u4e48\u5462\uff0c\u662fint\uff0c\u6700\u7ec8\u6211\u4eec\u5f97\u51fa\u6765\u4e00\u4e2a\u7ed3\u8bba\u2014\u2014\u8fd9\u662f\u4e00\u4e2a\u6307\u5411int\u7684\u6307\u9488\u5e38\u91cf\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u5c06line3\u548cline4\u5206\u6790\u6e05\u695a\u4e4b\u540e\uff0c\u5c31\u6765\u8bb2\u4e00\u8bb2\u5b83\u4eec\u7684\u6027\u8d28\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5e38\u91cf\u6307\u9488<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5148\u6765\u8bf4\u8bf4line3\u2014\u2014\u5e38\u91cf\u6307\u9488\uff0c\u5e38\u91cf\u6307\u9488\u662f\u5b83\u6307\u5411\u7684\u4e00\u4e2a\u503c\u662f\u5e38\u91cf\uff0c\u6211\u4eec\u77e5\u9053\u5e38\u91cf\u662f\u4e0d\u53ef\u66f4\u6539\u7684\uff0c\u6240\u4ee5\u5f53\u6211\u4eec\u89e3\u5f15\u7528\u7684\u65f6\u5019\uff0c\u8fd9\u79cd\u64cd\u4f5c\u662f\u9519\u7684\uff0c<code>*pa = *pa+1\uff1b<\/code>\u4f46\u662f\u8fd9\u662f\u6307\u9488\u6307\u5411\u7684\u503c\u88ab\u9650\u5236\u6210\u4e86\u5e38\u91cf\uff0c\u6211\u7684\u6307\u9488\u672c\u8eab\u6ca1\u6709\u9650\u5236\uff0c\u6240\u4ee5\u6211\u5b8c\u5168\u53ef\u4ee5\u6539\u53d8\u6307\u9488pa\u4e2d\u5b58\u653e\u7684\u5730\u5740\uff0c\u6bd4\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\nint main()\n{\n    const int a = 1;\/\/\u5e38\u91cf\n    const int a2 = 2;\/\/\u5e38\u91cf\n\n    const int *pa = &amp;a;\/\/\u5e38\u91cf\u6307\u9488\n    pa = &amp;a2;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u53ef\u4ee5\u5c06pa\u4e2d\u5b58\u653e\u7684\u5730\u5740\u4ecea\u7684\u5730\u5740\u6362\u6210a2\u7684\u5730\u5740\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u6765\u603b\u7ed3\u4e00\u4e0b\u2014\u2014<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u5e38\u91cf\u6307\u9488\u672c\u8eab\u7684\u5730\u5740\u53ef\u4ee5\u6539\u53d8\uff0c\u4f46\u662f\u5b83\u6307\u5411\u7684\u503c\u662f\u4e00\u4e2a\u5e38\u91cf\u6240\u4ee5\u4e0d\u80fd\u6539\u53d8<\/mark><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6307\u9488\u5e38\u91cf<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u63a5\u4e0b\u6765\u6211\u4eec\u8bf4\u8bf4line4\u2014\u2014\u6307\u9488\u5e38\u91cf\uff0c\u987e\u540d\u601d\u4e49\u662f\u4e00\u4e2a\u6307\u9488\u7684\u5e38\u91cf\uff0c\u8fd9\u4e2a\u6307\u9488\u672c\u8eab\u662f\u4e2a\u5e38\u91cf\uff0c\u5e38\u91cf\u4e0d\u53ef\u66f4\u6539\uff0c\u4f46\u662f\u6307\u9488\u672c\u8eab\u662f\u5e38\u91cf\u5173\u5b83\u6307\u5411\u7684\u53d8\u91cf\u4ec0\u4e48\u4e8b\uff0c\u6240\u4ee5\u5b83\u7684\u53d8\u91cf\u7684\u503c\u53ef\u4ee5\u6539\u53d8\uff0c\u6bd4\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\nint main()\n{\n    int b = 2;\/\/\u53d8\u91cf\n    int  *const pb = &amp;b;\/\/\u6307\u9488\u5e38\u91cf\n    *pb = 3;\/\/\u6211\u53ef\u4ee5\u5c06b\u7684\u503c\u4ece2\u6539\u62103\uff0c\u6240\u4ee5\u8fd9\u4e2a\u64cd\u4f5c\u662f\u5141\u8bb8\u7684\n    printf(\"b = %d\",*pb);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u8fd0\u884c\u7ed3\u679c<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">b = 3<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u770b\u5230b\u7684\u503c\u53d1\u751f\u4e86\u6539\u53d8\uff0c\u4f46\u662f\u5982\u679c\u6211\u4eec\u5c06pb\u672c\u8eab\u5b58\u653e\u7684\u5730\u5740\u6539\u4e00\u4e0b\u5462\uff1f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\nint main()\n{\n    int b = 2;\/\/\u53d8\u91cf\n    int b2 = 3;\n\n    int  *const pb = &amp;b;\/\/\u6307\u9488\u5e38\u91cf\n  \n    pb = &amp;b2;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u8fd0\u884c\u7ed3\u679c<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">error: assignment of read-only variable \u2018pb\u2019<br>pb = &amp;b2;<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u7f16\u8bd1\u5668\u629b\u51fa\u4e86\u4e00\u4e2a\u9519\u8bef\uff0cpb\u672c\u8eab\u7684\u5730\u5740\u4e0d\u5141\u8bb8\u66f4\u6539\uff0c\u56e0\u4e3a\u5b83\u662f\u4e00\u4e2a\u5e38\u91cf\uff0c\u8fd9\u5c31\u662f\u6307\u9488\u5e38\u91cf\uff0c\u6211\u4eec\u6765\u603b\u7ed3\u4e00\u4e0b\u2014\u2014<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u6307\u9488\u5e38\u91cf\u6240\u6307\u5411\u7684\u503c\u53ef\u4ee5\u66f4\u6539\uff0c\u4f46\u662f\u5b83\u672c\u8eab\u7684\u5730\u5740\u4e0d\u53ef\u4ee5\u66f4\u6539<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bf4\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u5982\u679c\u60f3\u5b9a\u4e49\u4e00\u4e2a\u6307\u5411\u7684\u503c\u548c\u5730\u5740\u90fd\u4e0d\u80fd\u66f4\u6539\u7684\u6307\u9488\u8be5\u600e\u4e48\u505a\u5462\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u5c31\u662f\u5e38\u91cf\u6307\u9488\u5e38\u91cf\uff0c\u6bd4\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n\nint main()\n{\n  const int a = 1;\n  const int *const p = &amp;a;\n\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6309\u7167\u6211\u4e4b\u524d\u63d0\u5230\u7684\u65b9\u6cd5\uff0c\u8bf7\u81ea\u884c\u5206\u6790\u4e00\u4e0b\uff0c\u76f8\u4fe1\u4f60\u4e00\u5b9a\u4e5f\u80fd\u7406\u89e3\u2014\u2014\u6307\u5411\u5e38\u91cf\u7684\u4e00\u4e2a\u6307\u9488\u5e38\u91cf\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6307\u9488\u4e0e\u6570\u7ec4\u4ee5\u53ca\u6307\u9488\u6570\u7ec4\u4e0e\u6570\u7ec4\u6307\u9488<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u6570\u7ec4\u8fd8\u4e0d\u4e86\u89e3\u7684\u8bfb\u8005\u53ef\u4ee5\u5148\u53c2\u8003\u4e00\u4e0b\u8fd9\u7bc7\u6587\u7ae0<a href=\"http:\/\/blog.chxzking.cn\/index.php\/2023\/11\/18\/%e5%a4%9a%e7%bb%b4%e6%95%b0%e7%bb%84%e7%9a%84%e6%9c%ac%e8%b4%a8\/\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\"><em>\u8bba\u6570\u7ec4<\/em><\/mark><\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u7bc7\u6587\u7ae0\u8f83\u4e3a\u8be6\u7ec6\u7684\u8bb2\u89e3\u4e86\u6307\u9488\u548c\u6570\u7ec4\u7684\u5173\u7cfb\uff0c\u8bfb\u8005\u53ef\u4ee5\u8df3\u8f6c\u8fc7\u53bb\uff0c\u91cc\u9762\u4e5f\u8be6\u7ec6\u8bb2\u89e3\u7684\u6570\u7ec4\u6307\u9488\u548c\u6307\u9488\u6570\u7ec4\u7684\u533a\u522b\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u76f8\u4fe1\u5927\u5bb6\u770b\u8fc7\u4e86\u524d\u9762\u6307\u9488\u5e38\u91cf\u548c\u5e38\u91cf\u6307\u9488\u7684\u547d\u540d\u89c4\u5219\uff0c\u4e5f\u8be5\u4e5f\u5bf9\u8fd9\u4e2a\u6807\u9898\u7684\u542b\u4e49\u6709\u4e86\u4e86\u89e3\uff0c\u5176\u5b9e\u8fd9\u91cc\u53ef\u4ee5\u62d3\u5c55\u4e00\u4e0b\uff0c\u6211\u4eec\u6839\u636e\u547d\u540d\u89c4\u5219\u53ef\u4ee5\u884d\u751f\u51fa\u5f88\u591a\u6982\u7387\uff0c\u751a\u81f3\u53ef\u4ee5\u65e0\u9650\u53e0\u52a0\uff0c\u6bd4\u5982\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6570\u7ec4\u6307\u9488\u6570\u7ec4\u2014\u2014\u8fd9\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c\u6570\u7ec4\u91cc\u9762\u5b58\u653e\u7684\u662f\u51e0\u4e2a\u6307\u5411\u5176\u4ed6\u6570\u7ec4\u7684\u6307\u9488\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6307\u9488\u6570\u7ec4\u6307\u9488\u2014\u2014\u8fd9\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u6307\u5411\u4e86\u4e00\u4e2a\u5b58\u653e\u7740\u6307\u9488\u7684\u6570\u7ec4\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6307\u9488\u6570\u7ec4\u6307\u9488\u6570\u7ec4\u2014\u2014\u8fd9\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c\u6570\u7ec4\u4e2d\u5b58\u653e\u7740\u51e0\u4e2a\u6307\u5411\u5b58\u653e\u6307\u9488\u7684\u6570\u7ec4\u7684\u6307\u9488\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6307\u9488\u6570\u7ec4\u6307\u9488\u6570\u7ec4\u6307\u9488\u2014\u2014\u8fd9\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u5b83\u6307\u5411\u4e86\u4e00\u4e2a\u6570\u7ec4\uff0c\u8fd9\u4e2a\u6570\u7ec4\u5b58\u653e\u7740\u5f88\u591a\u6307\u9488\uff0c\u8fd9\u4e9b\u6307\u9488\u53c8\u5206\u522b\u6307\u5411\u4e86\u67d0\u4e9b\u6570\u7ec4\uff0c\u8fd9\u4e9b\u6570\u7ec4\u4e2d\u5b58\u653e\u7684\u5185\u5bb9\u662f\u6307\u9488\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&#8230;&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u8fc7\u4e07\u53d8\u4e0d\u79bb\u5176\u5b97\uff0c\u6211\u4eec\u4ece\u540e\u5f80\u524d\u8bfb\uff0c\u5148\u5168\u90e8\u906e\u4f4f\uff0c\u7136\u540e\u4e00\u4e2a\u4e00\u4e2a\u548c\u6700\u540e\u7684\u90a3\u4e2a\u540d\u5b57\u53e0\u52a0\u8d77\u6765\uff0c\u5c31\u80fd\u5f88\u6e05\u6670\u7684\u770b\u61c2\u8fd9\u4e2a\u6982\u5ff5\u7684\u5b9a\u4e49\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6307\u9488\u51fd\u6570\u548c\u51fd\u6570\u6307\u9488<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f9d\u65e7\u662f\u524d\u9762\u8bf4\u8fc7\u7684\u601d\u60f3\uff0c\u6211\u4eec\u5c06\u6700\u540e\u4e00\u4e2a\u540d\u8bcd\u4fdd\u7559\uff0c\u906e\u4f4f\u524d\u9762\u7684\u4fee\u9970\u8bcd\uff0c\u7136\u540e\u5c31\u80fd\u6e05\u6670\u7684\u770b\u61c2\u8fd9\u4e2a\u6807\u9898\u5c06\u7684\u662f\u201c\u51fd\u6570\u548c\u6307\u9488\u201d<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6307\u9488\u51fd\u6570<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5148\u6765\u8bf4\u4e00\u8bf4\u6307\u9488\u51fd\u6570\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6309\u7167\u6211\u4eec\u4e4b\u524d\u7684\u601d\u60f3\uff0c\u6211\u4eec\u5728\u5f88\u5bb9\u6613\u63a8\u6d4b\u51fa\u6307\u9488\u51fd\u6570\u7684\u683c\u5f0f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6307\u9488\u51fd\u6570\u987e\u540d\u601d\u4e49\u5c31\u662f\u8fd4\u56de\u6307\u9488\u7684\u51fd\u6570\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u5199\u4e00\u4e2a\u51fd\u6570\u540d<code>func(int a);<\/code>\u7136\u540e\u52a0\u4e0a\u5b83\u7684\u8fd4\u56de\u503c <code>int *func(int a)<\/code>\uff0c\u8fd9\u5e76\u4e0d\u662f\u4ec0\u4e48\u5f88\u795e\u79d8\u7684\u4e1c\u897f\uff0c\u666e\u901a\u51fd\u6570\u53ef\u4ee5\u8fd4\u56dechar \u4e5f\u53ef\u4ee5\u8fd4\u56deint \u6307\u9488\u51fd\u6570\u53ea\u4e0d\u8fc7\u662f\u8fd4\u56de\u4e00\u4e2a\u6307\u9488\u7f62\u4e86\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u8fc7\uff0c\u6307\u9488\u51fd\u6570\u7684\u9886\u57df\u4e3b\u8981\u6d89\u53ca\u5230\u7684\u662f\u52a8\u6001\u5185\u5b58\u9886\u57df\u3002\u5728\u6211\u4eec\u5b66\u4e60\u90a3\u4e2a\u5730\u65b9\u4e4b\u524d\uff0c\u6211\u7684\u5efa\u8bae\u662f\u8fd9\u4e00\u90e8\u5206\u6682\u65f6\u505a\u4e86\u89e3\u5373\u53ef\uff0c\u56e0\u4e3a\u521d\u5b66\u8005\u5f88\u5bb9\u6613\u9020\u6210\u5185\u5b58\u6cc4\u6f0f\u548c\u8ba9\u6307\u9488\u53d8\u6210\u91ce\u6307\u9488\u7684\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u8fc7\u6b64\u5904\u6211\u8fd8\u662f\u7c97\u7565\u7684\u8bb2\u89e3\u4e00\u4e0b\u6307\u9488\u51fd\u6570\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n#include &lt;malloc.h&gt;\nint *func(int a){\n    int *data = (int*)malloc(sizeof(int));\/\/\u5728\u5806\u533a\u5f00\u8f9fint\u5927\u5c0f\u7684\u7a7a\u95f4\n    *data = a+10;\n    return data;\n}\nint main()\n{\n    int a;\n    int *p = func(a);\u6307\u9488\u63a5\u53d7\u8fd4\u56de\u7684\u51fd\u6570\u6307\u9488\n    printf(\"a = %d\\n\",*p);\n    free(p);\/\/\u91ca\u653e\u5806\u533a\u7a7a\u95f4\n    p = NULL;\/\/\u7f6e\u7a7a\u6307\u9488\uff0c\u9632\u6b62\u51fa\u73b0\u91ce\u6307\u9488\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u8fd0\u884c\u7ed3\u679c<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">a = 10<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u4f7f\u7528\u4e86\u4e00\u4e2a<code>int*<\/code>\u7684\u6307\u9488\u63a5\u4f4f\u4e86<code>func<\/code>\u51fd\u6570\u8fd4\u56de\u7684\u5806\u533a\u6307\u9488\uff0c\u7136\u540e\u64cd\u4f5c\uff0c\u4e4b\u540e\u8bb0\u5f97\u91ca\u653e\u7a7a\u95f4\u4ee5\u53ca\u7f6e\u7a7a\u6307\u9488\uff0c\u5426\u5219\u4f1a\u9020\u6210\u5185\u5b58\u6cc4\u6f0f\u548c\u6307\u9488\u60ac\u6302\uff0c\u4e5f\u5c31\u662f\u91ce\u6307\u9488\u3002\u5728<code>free<\/code>\u540e\u9762\u7d27\u8ddf\u7740\u7f6e\u7a7a\u6307\u9488\u662f\u4e00\u4e2a\u597d\u4e60\u60ef\uff0c\u8fd9\u4e2a\u6bd4\u8f83\u63a8\u5d07\u8bfb\u8005\u5b66\u4e60\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a\u5185\u5bb9\u5bf9\u4e8e\u521d\u5b66\u8005\u6765\u8bf4\u6709\u70b9\u8d85\u524d\uff0c\u53ea\u9700\u8981\u4e86\u89e3\u5373\u53ef<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u51fd\u6570\u6307\u9488<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u63a5\u4e0b\u6765\u770b\u4e00\u770b\u51fd\u6570\u6307\u9488\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u987e\u540d\u601d\u4e49\uff0c\u5b83\u662f\u4e00\u4e2a\u6307\u9488\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u5148\u6765\u770b\u5b83\u7684\u57fa\u672c\u683c\u5f0f\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">int (*func)(int a)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u548c\u6307\u9488\u51fd\u6570\u5f88\u50cf\uff0c\u4e0d\u8fc7\u533a\u522b\u662f\u51fd\u6570\u6307\u9488\u591a\u4e86\u4e00\u4e2a\u5c0f\u62ec\u53f7\u3002\u8fd9\u4e2a\u539f\u56e0\u6d89\u53ca\u5230\u4e86\u4f18\u5148\u7ea7\u7684\u95ee\u9898\uff0c()\u7684\u4f18\u5148\u7ea7\u662f\u5927\u4e8e*\u53f7\u7684\uff0c\u6240\u4ee5func\u4f1a\u5148\u548c(int a)\u7ed3\u5408\uff0c\u4f46\u662f\u8fd9\u6837\u5c31\u6210\u4e86\u6307\u9488\u51fd\u6570\u4e86\uff0c\u6240\u4ee5\u6211\u4eec\u52a0\u4e86\u62ec\u53f7\uff0c\u5f3a\u884c\u8ba9*\u548cfunc\u7ed3\u5408\uff0c\u8fd9\u4e2a\u53d8\u91cf\u5c31\u53d8\u6210\u4e86\u6307\u9488\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n\nint func(int a){\n    a+=10;\n    return a;\n}\nint main()\n{\n    int a = 1;\n    int (*p)(int)=NULL;\/\/\u51fd\u6570\u6307\u9488\n    p = func;\n    a = p(a);\n    printf(\"a = %d\\n\",a);\n\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u8fd0\u884c\u7ed3\u679c<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">a = 11<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u91cc\u9700\u8981\u8865\u5145\u4e00\u4e2a\u77e5\u8bc6\u70b9\uff0c\u51fd\u6570\u540d\u7684\u672c\u8d28\u4e5f\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u8fd9\u4e2a\u6307\u9488\u4e2d\u5b58\u653e\u4e86\u8fd9\u4e2a\u51fd\u6570\u7684\u5730\u5740\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e5f\u662f\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u51fd\u6570\u6307\u9488p = func\u800c\u4e0d\u9700\u8981\u53d6\u5730\u5740\u7684\u539f\u56e0\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u540e\u6211\u4eec\u7684\u6240\u6709\u64cd\u4f5c\u90fd\u53ef\u4ee5\u901a\u8fc7p\u6765\u8fdb\u884c\uff0c\u76f8\u5f53\u4e8ep\u53d6\u4ee3\u4e86func\uff0c\u5f53\u7136func\u4f9d\u65e7\u53ef\u4ee5\u4f7f\u7528\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u51fd\u6570\u6307\u9488\u7684\u5f15\u7528\u5176\u5b9e\u4e5f\u6bd4\u8f83\u5e7f\u6cdb\uff0c\u5728\u4f7f\u7528c\u8bed\u8a00\u5199\u5e95\u5c42\u7cfb\u7edf\u7684\u65f6\u5019\uff0c\u5728\u591a\u7ea7\u83dc\u5355\u680f\u8fd9\u4e9b\u529f\u80fd\u4e0a\u5e38\u5e38\u4f1a\u7528\u5230\u51fd\u6570\u6307\u9488\u8c03\u7528\u51fd\u6570\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u5728\u5b66\u4e60C\u8bed\u8a00\u7684\u65f6\u5019\uff0c\u5e38\u5e38\u4f1a\u56e0\u4e3a\u8001\u5e08\u6216\u8005\u4e66\u672c\u6ca1\u6709\u7ed9\u51fa\u5b9e\u9645\u8fd0\u7528\u7684\u4f8b\u5b50\uff0c\u800c\u89c9\u5f97\u67d0\u4e2a\u8bed\u6cd5\u65e0\u7528\uff0c\u5176\u5b9e\u53ea\u4e0d\u8fc7\u662f\u6211\u4eec\u8fd8\u672a\u63a5\u89e6\u5230\u7f62\u4e86\uff0c\u8fd9\u4e5f\u662f\u5b66C\u8bed\u8a00\u7684\u4e00\u9053\u574e\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6307\u9488\u548c\u52a8\u6001\u5185\u5b58\u5206\u914d<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a\u6a21\u5757\u5c31\u4e0d\u5c55\u5f00\u8bb2\u4e86\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u662f\u4e00\u4e2a\u5f88\u5927\u7684\u77e5\u8bc6\u677f\u5757\uff0c\u4e0d\u8fc7\u4ee5\u4e0b\u6709\u4e00\u4e9b\u5e38\u7528\u7684\u52a8\u6001\u5185\u5b58\u51fd\u6570\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">malloc()\uff1a\u5728\u5806\u533a\u5206\u914d\u4e00\u5757\u6307\u5b9a\u5927\u5c0f\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u7528\u6765\u5b58\u653e\u6570\u636e\u3002\u8fd9\u5757\u5185\u5b58\u7a7a\u95f4\u5728\u51fd\u6570\u6267\u884c\u5b8c\u6210\u540e\u4e0d\u4f1a\u88ab\u521d\u59cb\u5316\uff0c\u5b83\u4eec\u7684\u503c\u662f\u672a\u77e5\u7684\u3002<br>calloc()\uff1a\u5728\u5185\u5b58\u4e2d\u52a8\u6001\u5730\u5206\u914d num \u4e2a\u957f\u5ea6\u4e3a size \u7684\u8fde\u7eed\u7a7a\u95f4\uff0c\u5e76\u5c06\u6bcf\u4e00\u4e2a\u5b57\u8282\u90fd\u521d\u59cb\u5316\u4e3a 0\u3002\u6240\u4ee5\u5b83\u7684\u7ed3\u679c\u662f\u5206\u914d\u4e86 num*size \u4e2a\u5b57\u8282\u957f\u5ea6\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u5e76\u4e14\u6bcf\u4e2a\u5b57\u8282\u7684\u503c\u90fd\u662f \u3002<br>realloc()\uff1a\u8be5\u51fd\u6570\u91cd\u65b0\u5206\u914d\u5185\u5b58\uff0c\u628a\u5185\u5b58\u6269\u5c55\u5230 newsize\u3002\u5982\u679c\u8c03\u6574\u6210\u529f\uff0c\u5b83\u5c06\u8fd4\u56de\u4e00\u4e2a\u6307\u5411\u91cd\u65b0\u5206\u914d\u5185\u5b58\u7684\u6307\u9488\uff0c\u5426\u5219\u8fd4\u56de\u4e00\u4e2a\u7a7a\u6307\u9488\u3002<br>free()\uff1a\u8be5\u51fd\u6570\u91ca\u653e address \u6240\u6307\u5411\u7684\u5185\u5b58\u5757,\u91ca\u653e\u7684\u662f\u52a8\u6001\u5206\u914d\u7684\u5185\u5b58\u7a7a\u95f4\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8865\u5145<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u6613\u53d1\u751f\u91ce\u6307\u9488\u7684\u60c5\u51b5<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u91cc\u6211\u4eec\u8865\u5145\u4e00\u4e0b\u524d\u6587\u57cb\u4e0b\u7684\u91ce\u6307\u9488\u7684\u4f0f\u7b14\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u751f\u547d\u5468\u671f\u7ed3\u675f<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\u6211\u4eec\u6765\u8bf4\u4e00\u8bf4\u6307\u9488\u6240\u6307\u7684\u5bf9\u8c61\u6d88\u4ea1\u7684\u60c5\u51b5\uff0c\u6211\u4eec\u6765\u770b\u4e00\u770b\u4e0b\u9762\u7684\u4f8b\u5b50\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n\nint* func(){\n    int num = 10;\n    return &amp;num;\n}\nint main()\n{\n    int *a = NULL;\n    a = func();\n    printf(\"a = %d\\n\",*a);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\u80fd\u770b\u5230 a \u627f\u63a5\u4e86num\u7684\u5730\u5740\uff0c\u4f46\u662f\u5b9e\u9645\u4e0a\uff0c\u5728\u51fd\u6570func\u7684\u751f\u547d\u7ed3\u675f\u540e\uff0cnum\u4e5f\u5c31\u968f\u4e4b\u91ca\u653e\u4e86\uff0c\u6240\u4ee5\u6b64\u65f6\u51fa\u73b0\u4e86\u6240\u6307\u5bf9\u8c61\u6d88\u4ea1\uff0c\u90a3\u4e48a\u5c31\u987a\u5176\u81ea\u7136\u53d8\u6210\u4e86\u91ce\u6307\u9488\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u6307\u5411\u5806\u533a\u7684\u6307\u9488\u88ab\u91ca\u653e<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u53e6\u4e00\u79cd\u60c5\u51b5\u5c31\u662ffree\u548cdelete\u91ca\u653e\u5185\u5b58\u540e\u7684\u60c5\u51b5\uff0c\u8fd9\u91cc\u5c31\u7528free\u4f5c\u4e3a\u4f8b\u5b50<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n#include &lt;malloc.h&gt;\nint *func(int a){\n    int *data = (int*)malloc(sizeof(int));\/\/\u5728\u5806\u533a\u5f00\u8f9fint\u5927\u5c0f\u7684\u7a7a\u95f4\n    *data = a+10;\n    return data;\n}\nint main()\n{\n    int a;\n    int *p = func(a);\u6307\u9488\u63a5\u53d7\u8fd4\u56de\u7684\u51fd\u6570\u6307\u9488\n    printf(\"a = %d\\n\",*p);\n    free(p);\/\/\u91ca\u653e\u5806\u533a\u7a7a\u95f4\n    p = NULL;\/\/\u7f6e\u7a7a\u6307\u9488\uff0c\u9632\u6b62\u51fa\u73b0\u91ce\u6307\u9488\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a\u6307\u9488\u51fd\u6570\u7684\u4f8b\u5b50\u5c31\u5f88\u9002\u5408\uff0c\u6211\u4eec\u8fd9\u91cc\u770b\u5230\u4e86func\u8fd4\u56de\u4e86\u6307\u9488\uff0c\u7136\u540e\u88abp\u63a5\u4f4f\u4e86\uff0cfree\u91ca\u653e\u5185\u5b58\u540e\uff0cp\u4e5f\u5c31\u6210\u4e3a\u4e86\u91ce\u6307\u9488\uff0c\u6240\u4ee5\u9700\u8981\u7f6e\u7a7a\u6765\u6d88\u9664\u91ce\u6307\u9488\u7684\u9690\u60a3\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6570\u636e\u5728\u5185\u5b58\u4e2d\u7684\u5b58\u50a8<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6307\u9488\u5728\u5185\u5b58\u4e2d\u7684\u6700\u5c0f\u53ef\u5bfb\u5740\u5355\u4f4d\u901a\u5e38\u662f\u5b57\u8282\uff0c\u4e5f\u5c31\u662f\u8bf4\u4e00\u4e2a<code>int<\/code>\u7c7b\u578b\u7684\u6570\u636e\u5728\u5185\u5b58\u4e2d\u5176\u5b9e\u5305\u542b\u4e86\u56db\u4e2a\u5730\u5740\uff0c\u800c\u901a\u5e38<code>int*<\/code>\u7684\u6307\u9488\u6307\u5411\u7684\u662f\u6570\u636e\u7684\u9996\u5730\u5740\u3002\u8fd9\u4e2a\u5e95\u5c42\u903b\u8f91\u53d8\u7ed9\u4e86\u6211\u4eec\u66f4\u591a\u7684\u5bf9\u6570\u636e\u7684\u64cd\u4f5c\u65b9\u5f0f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u90a3\u4e48\u63a5\u4e0b\u6765\u5c31\u8ba9\u6211\u4eec\u89e3\u5f00\u5185\u5b58\u7684\u201c\u5e90\u5c71\u771f\u9762\u76ee\u201d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\nint main(){\n    \/*\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\u53d8\u91cfa\uff0cint\u7684\u5927\u5c0f\u662f4\u4e2a\u5b57\u8282\uff0c\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u5728\u903b\u8f91\u4e0a\u5c06\u5176\u5206\u6210\u56db\u4e2a\u533a\u5757\uff0c\n     *\u6bcf\u4e2a\u533a\u5757\u5b58\u4e00\u4e2a\u6570\uff0c\u5982\u4e0b\uff0c\u5206\u522b\u5b58\u50a81\u30013\u30017\u300115\uff0c\u4f46\u8fd9\u53ea\u662f\u903b\u8f91\u7684\uff0c\u5b9e\u9645\u4e0aa\u4f9d\u65e7\u8868\u793a\u4e00\n     *\u4e2a\u6574\u6570,\u8fd9\u4e2a\u6574\u6570\u752816\u8fdb\u5236\u8868\u793a0x103070f\n     *\/\n    int a=0x103070f;\/\/0000001 00000011 00000111 00001111 \n                    \/\/   1       3        7        15   \n    int *p = &amp;a;\n    printf(\" p = %p\\n\",p);\n    printf(\"*p = %d\\n\\n\",*p);\n    \n    \/*\u4e3a\u4e86\u76f4\u89c2\u548c\u5bb9\u6613\u7406\u89e3\uff0c\u6211\u6b64\u5904\u9009\u62e9\u4f7f\u7528\u6bd4\u8f83\u7e41\u7410\u7684\u5199\u6cd5\n     *\u6211\u4eec\u5728\u8fd9\u91cc\u5b9a\u4e49\u4e86\u4e00\u4e2a\u6570\u7ec4\uff0c\u6570\u7ec4\u5c31\u662f\u76f8\u540c\u7c7b\u578b\u7684\u5143\u7d20\u653e\u5728\u4e00\u8d77\uff0cb&#91;4]\u7684\u542b\u4e49\u5c31\u662fb\u91cc\u9762\u653e\u4e864\u4e2a\u5143      \n     *\u7d20\uff0c\u5206\u522b\u5b58\u653e\u4e86p\uff08\u6211\u4eec\u5c06p\u770b\u4f5ca\u4e2d\u56db\u4e2a\u5b57\u8282\u4e2d\u7684\u9996\u4e2a\u5143\u7d20\u7684\u5730\u5740\uff09\u7684\u5730\u5740\uff0c\u4ee5\u53cap+1\u3001p+2\u3001p+3\u7684\n     *\u5730\u5740\uff0c\u4e00\u5171\u56db\u4e2a\u5730\u5740\u3002\n     *\/\n    long long int b&#91;4] = {(long long int)p,(long long int)p+1,(long long int)p+2,(long long int)p+3};\n\n   \/\/\u6211\u4eec\u62ff\u51fa\u6570\u7ec4\u4e2d\u7b2c\u4e00\u4e2a\u5730\u5740\uff0cb&#91;0]\u4ee3\u8868\u7b2c\u4e00\u4e2a\u5143\u7d20\uff0c\u6211\u4eec\u5c06p\u5f3a\u5236\u8f6c\u6362\u4e3a\u5730\u5740\u3002\n   \/\/\u4e3a\u4ec0\u4e48\u4f7f\u7528char*\uff0c\u662f\u56e0\u4e3achar*\u521a\u597d\u662f\u4e00\u4e2a\u5b57\u8282\uff0c\u662f\u6700\u5c0f\u7684\u53ef\u5bfb\u5740\u5355\u4f4d\n    char *p1 = (char*)(b&#91;0]);\n    printf(\" p1 = %p\\n\",p1);\n    printf(\"*p1 = %d \\n\\n\",*p1);\n\n    char *p2 = (char*)(b&#91;1]);\n    printf(\" p2 = %p\\n\",p2);\n    printf(\"*p2 = %d \\n\\n\",*p2);\n\n    char *p3 = (char*)(b&#91;2]);\n    printf(\" p3 = %p\\n\",p3);\n    printf(\"*p3 = %d \\n\\n\",*p3);\n    \n    char *p4 = (char*)(b&#91;3]);\n    printf(\" p4 = %p\\n\",p4);\n    printf(\"*p4 = %d \\n\\n\",*p4);\n    \n    return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd0\u884c\u7ed3\u679c<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/blog.chxzking.cn\/wp-content\/uploads\/2023\/12\/4O54U43@33KZB1BDD7.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"296\" height=\"287\" data-original=\"http:\/\/blog.chxzking.cn\/wp-content\/uploads\/2023\/12\/4O54U43@33KZB1BDD7.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-227\"\/><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u4ece\u7ed3\u679c\u53ef\u4ee5\u770b\u51fa\uff0c\u8f93\u51fa\u7ed3\u679c\u548c\u6211\u4eec\u7684\u9884\u671f\u4e00\u6a21\u4e00\u6837\uff0ca\u7684\u5730\u5740\u662f\u5b83\u7684\u56db\u4e2a\u5730\u5740\u5757\u7684\u9996\u5143\u7d20\u5730\u5740\u6bcf\u4e2a\u5730\u5740\u5757\u90fd\u5b58\u653e\u4e86\u76f8\u5e94\u7684\u6570\u636e\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u8fc7\u7ec6\u5fc3\u7684\u8bfb\u8005\u5df2\u7ecf\u53d1\u73b0\u4e86\u4e00\u4e2a\u95ee\u9898\u2014\u2014\u4e3a\u4ec0\u4e48\u5730\u5740\u7684\u65b9\u5411\u548c\u6570\u636e\u7684\u65b9\u5411\u662f\u76f8\u53cd\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u5c31\u5f97\u63d0\u5230\u4e00\u4e2a\u6982\u5ff5\u2014\u2014<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">\u5b57\u8282\u5e8f<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b57\u8282\u5e8f\u5c31\u662f\u5185\u5b58\u4e2d\u6570\u636e\u7684\u987a\u5e8f\uff0c\u5206\u4e3a\u5927\u7aef\u5b57\u8282\u5e8f\u548c\u5c0f\u7aef\u5b57\u8282\u5e8f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5c0f\u7aef\u5b57\u8282\u5e8f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bf4\u5b57\u8282\u5e8f\u4e4b\u524d\u6211\u4eec\u5148\u8bf4\u4e00\u4e2a\u6982\u5ff5\uff0c\u6570\u636e\u7684\u9ad8\u4f4d\u4f4e\u4f4d\u548c\u5730\u5740\u7684\u9ad8\u4f4d\u4f4e\u4f4d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5148\u8bf4\u4e00\u8bf4\u5730\u5740\u7684\u9ad8\u4f4d\u4f4e\u4f4d\uff0c\u4e3a\u4e86\u4fbf\u4e8e\u7406\u89e3\uff0c\u6211\u4eec\u76f4\u63a5\u901a\u8fc7\u4ee5\u4e0b\u4f8b\u5b50\u6765\u8bb2\u89e3\uff0c\u5047\u8bbe\u6709\u4e24\u4e2a\u5730\u57400x0000\u548c0x0001\u8fd9\u4e2a\u5730\u5740\u7684\u4f4e\u4f4d\u5c31\u662f0x0000\uff0c\u9ad8\u4f4d\u5c31\u662f0x0001\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u518d\u8bf4\u4e00\u8bf4\u6570\u636e\u9ad8\u4f4d\uff0c\u8fd9\u4e2a\u548c\u5730\u5740\u6070\u6070\u76f8\u53cd\uff0c\u5047\u8bbe\u6709\u4e00\u4e2a16\u8fdb\u5236\u6570\uff0c0x12345678\uff0c\u5b83\u7684\u9ad8\u4f4d\u662f12\u7136\u540e\u662f34\u7b49\u7b49\uff0c\u81f3\u4e8e\u4e3a\u4ec0\u4e48\u662f\u4e24\u4e2a\u6570\uff0c\u56e0\u4e3a\u4e00\u4e2a\u5b57\u8282\u662f8\u4f4d\uff0c\u6700\u591a\u7684\u5b58\u50a8\u4e5f\u5c31\u662f11111111\uff0c\u6362\u7b97\u621016\u8fdb\u5236\u662fff\uff0c\u663e\u7136\u4e0d\u7ba1\u662f12\u8fd8\u662f34\u90fd\u662f\u5c0f\u4e8eff\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u63a5\u4e0b\u6765\u8c08\u8c08\u5c0f\u6bb5\u5b57\u8282\u5e8f\uff0c\u5c0f\u6bb5\u5b57\u8282\u5e8f\u5c31\u662f\u6570\u636e\u4f4e\u4f4d\u653e\u5728\u5730\u5740\u4f4e\u4f4d\uff0c\u6570\u636e\u9ad8\u4f4d\u653e\u5728\u5730\u5740\u9ad8\u4f4d\uff0c\u6240\u4ee5\u5982\u679c\u5730\u5740\u662f0x0000\u30010x0001\u30010x0002\u30010x0003\uff0c\u5728\u5b9e\u9645\u7684\u5b58\u653e\u8fc7\u7a0b\u4e2d\uff0c12 34 56 78\u5b58\u653e\u987a\u5e8f\u56e0\u8be5\u662f78 56 34 12\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f5c\u8005\u4f7f\u7528\u7684x86\u5e73\u53f0\u5219\u662f\u91c7\u7528\u7684\u5c0f\u7aef\u5b57\u8282\u5e8f<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5927\u7aef\u5b57\u8282\u5e8f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5927\u7aef\u5b57\u8282\u5e8f\u662f\u9ad8\u4f4d\u5b57\u8282\u653e\u5728\u4f4e\u4f4d\u5730\u5740\u4e2d\uff0c\u4f4e\u4f4d\u5b57\u8282\u653e\u5728\u9ad8\u4f4d\u5730\u5740\u4e2d\uff0c\u548c\u5c0f\u7aef\u5b57\u8282\u5e8f\u76f8\u53cd\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u4f9d\u65e7\u91c7\u7528\u4e0a\u9762\u7684\u4f8b\u5b50\uff0c\u5982\u679c\u5728\u5927\u7aef\u5b57\u8282\u5e8f\u5b58\u50a8\uff0c\u82e5\u5730\u5740\u662f0x0000\u30010x0001\u30010x0002\u30010x0003\uff0c\u5728\u5b9e\u9645\u7684\u5b58\u653e\u8fc7\u7a0b\u4e2d\uff0c12 34 56 78\u5b58\u653e\u987a\u5e8f\u56e0\u8be5\u662f12 34 56 78\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u8fd0\u884c\u73af\u5883\uff1acentos7\uff08 Linux\uff09 \u7f16\u8bd1\u5668: gcc 9.3.1 64\u4f4d \u6307\u9488\u662f\u4ec0\u4e48 \u5730\u5740\u662f\u5185\u5b58\u7a7a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":762,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[17,18,22],"class_list":["post-184","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-c","tag-c-2","tag-c","tag-pointer"],"_links":{"self":[{"href":"http:\/\/blog.chxzking.cn\/index.php\/wp-json\/wp\/v2\/posts\/184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.chxzking.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.chxzking.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.chxzking.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.chxzking.cn\/index.php\/wp-json\/wp\/v2\/comments?post=184"}],"version-history":[{"count":7,"href":"http:\/\/blog.chxzking.cn\/index.php\/wp-json\/wp\/v2\/posts\/184\/revisions"}],"predecessor-version":[{"id":751,"href":"http:\/\/blog.chxzking.cn\/index.php\/wp-json\/wp\/v2\/posts\/184\/revisions\/751"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/blog.chxzking.cn\/index.php\/wp-json\/wp\/v2\/media\/762"}],"wp:attachment":[{"href":"http:\/\/blog.chxzking.cn\/index.php\/wp-json\/wp\/v2\/media?parent=184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.chxzking.cn\/index.php\/wp-json\/wp\/v2\/categories?post=184"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.chxzking.cn\/index.php\/wp-json\/wp\/v2\/tags?post=184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}