{"id":286,"date":"2025-11-30T20:49:57","date_gmt":"2025-11-30T12:49:57","guid":{"rendered":"http:\/\/4.189.252.43\/?p=286"},"modified":"2025-11-30T20:49:58","modified_gmt":"2025-11-30T12:49:58","slug":"%e6%8c%87%e9%92%88","status":"publish","type":"post","link":"http:\/\/4.189.252.43\/index.php\/2025\/11\/30\/%e6%8c%87%e9%92%88\/","title":{"rendered":"\u6307\u9488"},"content":{"rendered":"\n<h2>1. \u6307\u9488\u7684\u672c\u8d28<\/h2>\n<p>\u6307\u9488\u662f<strong>\u5b58\u50a8\u5185\u5b58\u5730\u5740\u7684\u53d8\u91cf<\/strong>\u3002<\/p>\n<p>int a = 1;<\/p>\n<p>float b = 0.1;<\/p>\n<p>\u6307\u9488 p = \u5730\u5740<\/p>\n<p>\u666e\u901a\u53d8\u91cf\u5b58\u50a8\u6570\u636e\u672c\u8eab\uff1b\u6307\u9488\u53d8\u91cf\u5b58\u50a8\u7684\u662f\u67d0\u4e2a\u6570\u636e\u5728\u5185\u5b58\u4e2d\u7684\u4f4d\u7f6e\u3002<\/p>\n<p>\u5185\u5b58\u4e2d\u6bcf\u4e2a\u5b57\u8282\u90fd\u6709\u552f\u4e00\u7684\u5730\u5740\uff0c\u5982\u679c\u5185\u5b58\u4e2d\u6709<span class=\"MathJax_SVG\" tabindex=\"-1\" style=\"font-size: 100%; display: inline-block;\"><svg xmlns:xlink=\"http:\/\/www.w3.org\/1999\/xlink\" width=\"1.394ex\" height=\"1.41ex\" viewBox=\"0 -504.6 600 607.1\" role=\"img\" focusable=\"false\" style=\"vertical-align: -0.238ex;\"><defs><path stroke-width=\"0\" id=\"E2-MJMATHI-6E\" d=\"M21 287Q22 293 24 303T36 341T56 388T89 425T135 442Q171 442 195 424T225 390T231 369Q231 367 232 367L243 378Q304 442 382 442Q436 442 469 415T503 336T465 179T427 52Q427 26 444 26Q450 26 453 27Q482 32 505 65T540 145Q542 153 560 153Q580 153 580 145Q580 144 576 130Q568 101 554 73T508 17T439 -10Q392 -10 371 17T350 73Q350 92 386 193T423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 180T152 343Q153 348 153 366Q153 405 129 405Q91 405 66 305Q60 285 60 284Q58 278 41 278H27Q21 284 21 287Z\"><\/path><\/defs><g stroke=\"currentColor\" fill=\"currentColor\" stroke-width=\"0\" transform=\"matrix(1 0 0 -1 0 0)\"><use xlink:href=\"#E2-MJMATHI-6E\" x=\"0\" y=\"0\"><\/use><\/g><\/svg><\/span><script type=\"math\/tex\">n<\/script>\u4e2a\u5b57\u8282\uff0c\u5176\u5b57\u8282\u5730\u5740\u53ef\u7f16\u53f7\u4e3a<span class=\"MathJax_SVG\" tabindex=\"-1\" style=\"font-size: 100%; display: inline-block;\"><svg xmlns:xlink=\"http:\/\/www.w3.org\/1999\/xlink\" width=\"9.653ex\" height=\"2.11ex\" viewBox=\"0 -755.9 4156 908.7\" role=\"img\" focusable=\"false\" style=\"vertical-align: -0.355ex;\"><defs><path stroke-width=\"0\" id=\"E3-MJMAIN-30\" d=\"M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z\"><\/path><path stroke-width=\"0\" id=\"E3-MJMAIN-223C\" d=\"M55 166Q55 241 101 304T222 367Q260 367 296 349T362 304T421 252T484 208T554 189Q616 189 655 236T694 338Q694 350 698 358T708 367Q722 367 722 334Q722 260 677 197T562 134H554Q517 134 481 152T414 196T355 248T292 293T223 311Q179 311 145 286Q109 257 96 218T80 156T69 133Q55 133 55 166Z\"><\/path><path stroke-width=\"0\" id=\"E3-MJMATHI-6E\" d=\"M21 287Q22 293 24 303T36 341T56 388T89 425T135 442Q171 442 195 424T225 390T231 369Q231 367 232 367L243 378Q304 442 382 442Q436 442 469 415T503 336T465 179T427 52Q427 26 444 26Q450 26 453 27Q482 32 505 65T540 145Q542 153 560 153Q580 153 580 145Q580 144 576 130Q568 101 554 73T508 17T439 -10Q392 -10 371 17T350 73Q350 92 386 193T423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 180T152 343Q153 348 153 366Q153 405 129 405Q91 405 66 305Q60 285 60 284Q58 278 41 278H27Q21 284 21 287Z\"><\/path><path stroke-width=\"0\" id=\"E3-MJMAIN-2212\" d=\"M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z\"><\/path><path stroke-width=\"0\" id=\"E3-MJMAIN-31\" d=\"M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z\"><\/path><\/defs><g stroke=\"currentColor\" fill=\"currentColor\" stroke-width=\"0\" transform=\"matrix(1 0 0 -1 0 0)\"><use xlink:href=\"#E3-MJMAIN-30\" x=\"0\" y=\"0\"><\/use><use xlink:href=\"#E3-MJMAIN-223C\" x=\"777\" y=\"0\"><\/use><use xlink:href=\"#E3-MJMATHI-6E\" x=\"1833\" y=\"0\"><\/use><use xlink:href=\"#E3-MJMAIN-2212\" x=\"2655\" y=\"0\"><\/use><use xlink:href=\"#E3-MJMAIN-31\" x=\"3656\" y=\"0\"><\/use><\/g><\/svg><\/span><script type=\"math\/tex\">0 \\sim n - 1<\/script><\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre><code>int a = 10;\nint *p = &amp;a;  \/\/ p \u4e2d\u5b58\u653e a \u7684\u5730\u5740\n<\/code><\/pre>\n<hr \/>\n<h2>2. \u6307\u9488\u7684\u58f0\u660e\u4e0e\u521d\u59cb\u5316<\/h2>\n<h3>2.1 \u58f0\u660e<\/h3>\n<pre><code>\u7c7b\u578b *\u6307\u9488\u540d;\n<\/code><\/pre>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre><code>int *p;      \/\/ \u6307\u5411 int \u7684\u6307\u9488\ndouble *q;   \/\/ \u6307\u5411 double \u7684\u6307\u9488\n<\/code><\/pre>\n<h3>2.2 \u521d\u59cb\u5316<\/h3>\n<pre><code>int a = 5;\nint *p = &amp;a;\n<\/code><\/pre>\n<p><code>&amp;<\/code>\uff1a\u8868\u793a\u53d6\u53d8\u91cf\u7684\u5730\u5740<\/p>\n<p>\u672a\u521d\u59cb\u5316\u7684\u6307\u9488\u5c5e\u4e8e\u201c\u91ce\u6307\u9488\u201d\uff0c\u5371\u9669\u4e14\u4e0d\u53ef\u4f7f\u7528\u3002<\/p>\n<hr \/>\n<h2>3. \u6307\u9488\u7684\u89e3\u5f15\u7528\uff08dereference\uff09<\/h2>\n<p>\u89e3\u5f15\u7528\u6307\u901a\u8fc7\u6307\u9488\u8bbf\u95ee\u6307\u5411\u7684\u53d8\u91cf\u3002<\/p>\n<pre><code>int a = 10;\nint *p = &amp;a;\n\n*p == a\n\nprintf(&quot;%d\\n&quot;, *p); \/\/ \u8f93\u51fa 10\n*p = 20;            \/\/ \u4fee\u6539 a \u7684\u503c\u4e3a 20\n<\/code><\/pre>\n<hr \/>\n<h2>4. \u6307\u9488\u4e0e\u6570\u7ec4<\/h2>\n<h3>4.1 \u6570\u7ec4\u540d\u662f\u4e0d\u53ef\u4fee\u6539\u7684\u6307\u9488\u5e38\u91cf(\u6307\u5411\u7684\u5185\u5b58\u4e0d\u53d8)<\/h3>\n<pre><code>int arr[3] = {1,2,3};\nint *p = arr;     \/\/ \u7b49\u4ef7\u4e8e &amp;arr[0]\n\nprintf(&quot;%d\\n&quot;, *(p+1));  \/\/ \u8f93\u51fa 2   \u79fb\u52a8\u4e86 1 * sizeof(int) = 4\n<\/code><\/pre>\n<p>\u6307\u9488 + n \u5b9e\u9645\u79fb\u52a8 <code>n \u00d7 sizeof(\u7c7b\u578b)<\/code> \u5b57\u8282\u4f4d\u7f6e\u3002<\/p>\n<h3>4.2 \u6307\u9488\u8fd0\u7b97<\/h3>\n<p>++\u4f18\u5148\u7ea7\u5927\u4e8e*<\/p>\n<figure><table>\n<thead>\n<tr><th>* p++<\/th><th>\u53d6\u5f53\u524d\u6307\u9488 <code>p<\/code> \u6307\u5411\u7684\u5143\u7d20\u7684\u503c\u3002<strong>\u8868\u8fbe\u5f0f\u7ed3\u675f\u540e\uff0cp \u81ea\u589e 1<\/strong>\uff0c\u6307\u5411\u4e0b\u4e00\u4e2a\u5143\u7d20\u3002\uff08\u5bf9\u5f53\u524d\u5143\u7d20\u89e3\u5f15\u7528\uff0c\u7136\u540e\u6307\u9488\u540e\u79fb\u3002\uff09<\/th><\/tr><\/thead>\n<tbody><tr><td>*(p++)<\/td><td>\u53d6\u5f53\u524d\u6307\u9488 <code>p<\/code> \u6307\u5411\u7684\u5143\u7d20\u7684\u503c\u3002\u8868\u8fbe\u5f0f\u7ed3\u675f\u540e\uff0cp \u81ea\u589e 1\uff0c\u6307\u5411\u4e0b\u4e00\u4e2a\u5143\u7d20\u3002\uff08\u5bf9\u5f53\u524d\u5143\u7d20\u89e3\u5f15\u7528\uff0c\u7136\u540e\u6307\u9488\u540e\u79fb\u3002\uff09<\/td><\/tr><tr><td>(*p)++<\/td><td>\u8fd4\u56de\uff1a\u539f\u6765\u7684 <code>*p<\/code>\uff0c \u526f\u4f5c\u7528\uff1a<code>*p = *p + 1<\/code>\uff0c<code>p<\/code> \u4e0d\u79fb\u52a8<\/td><\/tr><tr><td>++*p<\/td><td>\u526f\u4f5c\u7528\uff1a<code>*p = *p + 1<\/code> \uff0c\u8fd4\u56de\uff1a\u65b0\u7684 <code>*p<\/code>\uff0c<code>p<\/code> \u4e0d\u79fb\u52a8<\/td><\/tr><tr><td>++(*p)<\/td><td>\u540c\u4e0a<\/td><\/tr><tr><td>*++P<\/td><td><code>p<\/code> \u5148\u9012\u589e\uff0c\u6307\u5411\u4e0b\u4e00\u4e2a\u5143\u7d20\u3002\u89e3\u5f15\u7528\u65b0\u4f4d\u7f6e\u7684\u503c\u3002<\/td><\/tr><tr><td>*(++p)<\/td><td>\u540c\u4e0a<\/td><\/tr><\/tbody>\n<\/table><\/figure>\n<hr \/>\n<h2>5. \u6307\u9488\u4e0e\u51fd\u6570<\/h2>\n<h3>5.1 \u901a\u8fc7\u6307\u9488\u5b9e\u73b0\u201c\u4f20\u5f15\u7528\u201d<\/h3>\n<p>\u7528\u4e8e\u51fd\u6570\u5185\u90e8\u4fee\u6539\u5916\u90e8\u53d8\u91cf\u3002<\/p>\n<pre><code>void set(int *x) {\n    *x = 100;\n}\n\nint main() {\n    int a = 5;\n    set(&amp;a);\n}\n<\/code><\/pre>\n<h3>5.2 \u6307\u9488\u4f5c\u4e3a\u6570\u7ec4\u53c2\u6570<\/h3>\n<p>\u907f\u514d\u590d\u5236\u5927\u6570\u7ec4\u3002<\/p>\n<pre><code class='language-\\\\' lang='\\\\'>void print(int *arr, int n) {\n    for(int i = 0; i &lt; n; i++) {\n        printf(&quot;%d &quot;, arr[i]);\n    }\n}\n<\/code><\/pre>\n<p><code>*(arr + i) == arr[i]<\/code><\/p>\n<hr \/>\n<h2>6. \u591a\u7ea7\u6307\u9488<\/h2>\n<p>\u8868\u793a\u6307\u5411\u6307\u9488\u7684\u6307\u9488\u3002<\/p>\n<pre><code>int a = 10;\nint *p = &amp;a;\nint **pp = &amp;p;\n(int *) *pp = &amp;p;\n*pp = p\n**pp = *(*pp) = *p = a\nprintf(&quot;%d\\n&quot;, **pp); \/\/ \u8f93\u51fa 10\n<\/code><\/pre>\n<p>\u5178\u578b\u7528\u4f8b\uff1a<\/p>\n<ul>\n<li>\u7ba1\u7406\u4e8c\u7ef4\u52a8\u6001\u6570\u7ec4<\/li>\n<li>\u4fee\u6539\u51fd\u6570\u5185\u90e8\u7684\u6307\u9488\uff08\u5982 <code>malloc<\/code> \u5c01\u88c5\uff09<\/li>\n\n<\/ul>\n<hr \/>\n<h2>7. \u52a8\u6001\u5185\u5b58\u4e0e\u6307\u9488<\/h2>\n<p>\u4f7f\u7528 <code>malloc<\/code> \/ <code>calloc<\/code> \/ <code>realloc<\/code> \u52a8\u6001\u7533\u8bf7\u5185\u5b58\u540e\u901a\u8fc7\u6307\u9488\u8bbf\u95ee\u3002<\/p>\n<pre><code>int *p = malloc(sizeof(int) * 5);\np[0] = 1;\nfree(p);\np = malloc(sizeof(int) * 10);\n<\/code><\/pre>\n<p>\u6ce8\u610f\u4e8b\u9879\uff1a<\/p>\n<ol>\n<li>\u7533\u8bf7\u540e\u5fc5\u987b\u68c0\u67e5\u662f\u5426\u4e3a <code>NULL<\/code><\/li>\n<li>\u4f7f\u7528\u5b8c\u6bd5\u5fc5\u987b <code>free<\/code><\/li>\n<li><code>free<\/code> \u540e\u5c06\u6307\u9488\u7f6e\u4e3a <code>NULL<\/code>\uff0c\u907f\u514d\u60ac\u6302\u6307\u9488<\/li>\n\n<\/ol>\n<hr \/>\n<h2>8. \u6307\u9488\u7684\u8d4b\u503c\u4e0e\u7c7b\u578b\u8f6c\u6362 <\/h2>\n<h3>\u4e0d\u540c\u7c7b\u578b\u6307\u9488\u4e0d\u53ef\u76f4\u63a5\u8d4b\u503c<\/h3>\n<p>C \u8bed\u8a00\u4e2d\uff0c\u6307\u9488\u7c7b\u578b\u5fc5\u987b\u4e0e\u6240\u6307\u5411\u5bf9\u8c61\u7684\u7c7b\u578b\u4e00\u81f4\uff1b\u4e0d\u540c\u7c7b\u578b\u7684\u6307\u9488\u4e0d\u80fd\u5728\u672a\u8f6c\u6362\u7684\u60c5\u51b5\u4e0b\u76f8\u4e92\u8d4b\u503c\u3002<\/p>\n<p>\u9519\u8bef\u793a\u4f8b\uff1a<\/p>\n<pre><code>int *p;\nchar *q;\n\nq = p;     \/\/ \u7c7b\u578b\u4e0d\u517c\u5bb9\uff0c\u7f16\u8bd1\u5668\u5c06\u7ed9\u51fa\u8b66\u544a\u6216\u9519\u8bef\n<\/code><\/pre>\n<p>\u539f\u56e0\uff1a\n \u4e0d\u540c\u6307\u9488\u7c7b\u578b\u89e3\u8bfb\u5185\u5b58\u7684\u65b9\u5f0f\u4e0d\u540c\uff08\u8bbf\u95ee\u7c92\u5ea6\u3001\u5bf9\u9f50\u8981\u6c42\u3001\u6b65\u8fdb\u65b9\u5f0f\u90fd\u4e0d\u540c\uff09\u3002\u76f4\u63a5\u8d4b\u503c\u4f1a\u5bfc\u81f4\u884c\u4e3a\u9519\u8bef\u3002<\/p>\n<hr \/>\n<h3><code>void*<\/code> \u6307\u9488<\/h3>\n<h4>1 \u542b\u4e49<\/h4>\n<p><code>void *<\/code> \u8868\u793a\u201c\u6307\u5411\u672a\u77e5\u7c7b\u578b\u201d\u7684\u6307\u9488\uff0c\u5373<strong>\u901a\u7528\u6307\u9488\u7c7b\u578b<\/strong>\u3002\n \u7279\u70b9\uff1a<\/p>\n<ul>\n<li>\u4e0d\u77e5\u9053\u6307\u5411\u7684\u5bf9\u8c61\u7684\u7c7b\u578b<\/li>\n<li>\u4e0d\u652f\u6301\u89e3\u5f15\u7528 (<code>*q<\/code> \u975e\u6cd5)<\/li>\n<li>\u4e0d\u652f\u6301\u6307\u9488\u7b97\u672f\u8fd0\u7b97 (<code>q+1<\/code> \u975e\u6cd5)<\/li>\n<li>\u53ef\u4ee5\u63a5\u6536\u201c\u4efb\u610f\u7c7b\u578b\u6307\u9488\u201d\u7684\u8d4b\u503c<\/li>\n<li>\u53ef\u4ee5\u8d4b\u503c\u7ed9\u201c\u4efb\u610f\u7c7b\u578b\u6307\u9488\u201d\uff0c\u4f46\u9700\u8981\u663e\u5f0f\u8f6c\u6362<\/li>\n\n<\/ul>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre><code>int *p = &amp;i;\nvoid *q = p;    \/\/ \u6b63\u786e\uff0cint* -&gt; void*\n<\/code><\/pre>\n<hr \/>\n<h3>\u6307\u9488\u7c7b\u578b\u8f6c\u6362<\/h3>\n<h4>1 \u663e\u5f0f\u8f6c\u6362<\/h4>\n<p>\u6307\u9488\u53ef\u4ee5\u901a\u8fc7\u663e\u5f0f\u7c7b\u578b\u8f6c\u6362\u6539\u53d8\u201c\u8bbf\u95ee\u5185\u5b58\u7684\u89c6\u89d2\u201d\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre><code>int  i = 0x12345678;\nint *p = &amp;i;\nvoid *q = (void *)p;     \/\/ p \u7ed9 q\uff0c\u7c7b\u578b\u53d8\u4e3a void*\n<\/code><\/pre>\n<p>\u6b64\u65f6\uff1a<\/p>\n<ul>\n<li><code>p<\/code> \u6309 int \u89c6\u89d2\u89e3\u8bfb\u5185\u5b58\uff08\u901a\u5e38 4 \u5b57\u8282\uff09<\/li>\n<li><code>q<\/code> \u4e0d\u77e5\u9053\u7c7b\u578b\uff0c\u65e0\u6cd5\u76f4\u63a5\u89e3\u8bfb<\/li>\n<li>\u82e5\u5c06 <code>q<\/code> \u8f6c\u6362\u4e3a <code>char*<\/code>\uff0c\u5219\u5185\u5b58\u53d8\u6210\u6309\u5b57\u8282\u89e3\u8bfb<\/li>\n\n<\/ul>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre><code>char *c = (char *)q;    \/\/ \u73b0\u5728\u6309 1 \u5b57\u8282\u8bfb\u5185\u5b58\n\nprintf(&quot;%02x\\n&quot;, c[0]); \/\/ i \u7684\u4f4e\u5b57\u8282\n<\/code><\/pre>\n<h4>2 \u201c\u901a\u8fc7 q \u89e3\u8bfb\u5185\u5b58\u7684\u89c6\u89d2\u53d8\u4e86\u201d<\/h4>\n<p>\u8fd9\u53e5\u7684\u6280\u672f\u610f\u4e49\u662f\uff1a<\/p>\n<p><strong>\u6307\u9488\u7c7b\u578b\u51b3\u5b9a\u4e86\u89e3\u91ca\u5185\u5b58\u7684\u5355\u4f4d\u4e0e\u65b9\u5f0f<\/strong><\/p>\n<ul>\n<li><code>int*<\/code> \u2192 \u6bcf\u6b21\u89e3\u5f15\u7528\u8bfb\u53d6 <code>sizeof(int)<\/code> \u5b57\u8282<\/li>\n<li><code>char*<\/code> \u2192 \u6bcf\u6b21\u89e3\u5f15\u7528\u8bfb\u53d6 1 \u5b57\u8282<\/li>\n<li><code>void*<\/code> \u2192 \u65e0\u6cd5\u89e3\u5f15\u7528\uff0c\u5fc5\u987b\u5148\u8f6c\u6362\u7c7b\u578b<\/li>\n<li><code>double*<\/code> \u2192 \u6bcf\u6b21\u89e3\u5f15\u7528\u8bfb\u53d6 <code>sizeof(double)<\/code> \u5b57\u8282<\/li>\n\n<\/ul>\n<p>\u56e0\u6b64\uff0c<strong>\u6539\u53d8\u6307\u9488\u7c7b\u578b\u5373\u6539\u53d8\u67e5\u770b\u5185\u5b58\u7684\u65b9\u5f0f<\/strong>\u3002<\/p>\n<p>\u8fd9\u662f C \u8bed\u8a00\u4e2d\u975e\u5e38\u91cd\u8981\u4e14\u9700\u8981\u8c28\u614e\u4f7f\u7528\u7684\u673a\u5236\u3002<\/p>\n<hr \/>\n<h3>4. \u793a\u4f8b\uff1a\u540c\u4e00\u5730\u5740\uff0c\u4e0d\u540c\u89c6\u89d2<\/h3>\n<pre><code>int i = 0x11223344;\n\nint *p = &amp;i;         \/\/ \u63094\u5b57\u8282\u6574\u6570\u8bfb\u53d6\nchar *c = (char*)&amp;i; \/\/ \u6309\u5b57\u8282\u8bfb\u53d6\n<\/code><\/pre>\n<p>\u5185\u5b58\uff08\u5047\u8bbe\u5c0f\u7aef\u673a\uff09\uff1a<\/p>\n<figure><table>\n<thead>\n<tr><th>\u5730\u5740<\/th><th>\u5185\u5bb9<\/th><\/tr><\/thead>\n<tbody><tr><td>&amp;i+0<\/td><td>44<\/td><\/tr><tr><td>&amp;i+1<\/td><td>33<\/td><\/tr><tr><td>&amp;i+2<\/td><td>22<\/td><\/tr><tr><td>&amp;i+3<\/td><td>11<\/td><\/tr><\/tbody>\n<\/table><\/figure>\n<p>\u8bbf\u95ee\u5dee\u5f02\uff1a<\/p>\n<pre><code>printf(&quot;%x\\n&quot;, *p); \/\/ 11223344\nprintf(&quot;%x\\n&quot;, c[0]); \/\/ 44\nprintf(&quot;%x\\n&quot;, c[1]); \/\/ 33\n<\/code><\/pre>\n<hr \/>\n<h3>5. \u5408\u6cd5\u4f46\u5371\u9669\u7684\u884c\u4e3a<\/h3>\n<p>C \u7684\u7c7b\u578b\u8f6c\u6362\u529f\u80fd\u5f3a\u5927\uff0c\u4f46\u5fc5\u987b\u6ce8\u610f\uff1a<\/p>\n<ul>\n<li>\u82e5\u6309\u9519\u8bef\u7c7b\u578b\u8bbf\u95ee\u5185\u5b58\uff0c\u53ef\u80fd\u7834\u574f\u5bf9\u9f50\u8981\u6c42<\/li>\n<li>\u53ef\u80fd\u5bfc\u81f4\u672a\u5b9a\u4e49\u884c\u4e3a\uff08UB\uff09<\/li>\n<li>\u7528\u4e8e\u89e3\u6790\u4e8c\u8fdb\u5236\u534f\u8bae\u3001\u5185\u5b58\u5206\u6790\u3001\u5b57\u8282\u5e8f\u8f6c\u6362\u65f6\u9700\u8981\u7cbe\u786e\u63a7\u5236<\/li>\n\n<\/ul>\n<h2>8. \u51fd\u6570\u6307\u9488<\/h2>\n<p>\u7528\u4e8e\u6307\u5411\u51fd\u6570\u5165\u53e3\u5730\u5740\u3002<\/p>\n<h3>\u58f0\u660e\u65b9\u5f0f\uff1a<\/h3>\n<pre><code>\u8fd4\u56de\u7c7b\u578b (*\u6307\u9488\u540d)(\u53c2\u6570\u7c7b\u578b\u5217\u8868)\n<\/code><\/pre>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre><code>int add(int a, int b) { return a+b; }\nint (*fp)(int,int) = add;\n\nint r = fp(3,4);  \/\/ \u8c03\u7528 add\n<\/code><\/pre>\n<p>\u5e94\u7528\u573a\u666f\uff1a<\/p>\n<ul>\n<li>\u56de\u8c03\u673a\u5236<\/li>\n<li>\u72b6\u6001\u673a<\/li>\n<li>\u51fd\u6570\u8868<\/li>\n\n<\/ul>\n<hr \/>\n<h2>9. \u6307\u9488\u5e38\u89c1\u9519\u8bef\u4e0e\u98ce\u9669<\/h2>\n<ol>\n<li><strong>\u91ce\u6307\u9488\uff08\u672a\u521d\u59cb\u5316\uff09<\/strong><\/li>\n<li><strong>\u60ac\u6302\u6307\u9488\uff08free \u540e\u7ee7\u7eed\u4f7f\u7528\uff09<\/strong><\/li>\n<li><strong>\u8d8a\u754c\u8bbf\u95ee<\/strong><\/li>\n<li><strong>\u6307\u9488\u7c7b\u578b\u4e0d\u5339\u914d<\/strong><\/li>\n<li><strong>\u91cd\u590d\u91ca\u653e\u5bfc\u81f4\u5d29\u6e83<\/strong><\/li>\n\n<\/ol>\n<p>\u793a\u4f8b\uff08\u9519\u8bef\uff09\uff1a<\/p>\n<pre><code>int *p;\n*p = 10;   \/\/ \u672a\u521d\u59cb\u5316\u76f4\u63a5\u4f7f\u7528\n<\/code><\/pre>\n<hr \/>\n<h2>10. \u6307\u9488\u4e0e <code>const<\/code><\/h2>\n<h3>10.1 \u6307\u5411\u5e38\u91cf\u7684\u6307\u9488<\/h3>\n<pre><code>const int *p;  \/\/ \u4e0d\u5141\u8bb8 *p \u88ab\u4fee\u6539\n<\/code><\/pre>\n<h3>10.2 \u6307\u9488\u672c\u8eab\u4e3a\u5e38\u91cf<\/h3>\n<pre><code>int * const p; \/\/ p \u4e0d\u53ef\u88ab\u91cd\u65b0\u8d4b\u5730\u5740\n<\/code><\/pre>\n<h3>10.3 \u90fd\u4e3a\u5e38\u91cf<\/h3>\n<pre><code>const int * const p;\n<\/code><\/pre>\n\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u6307\u9488\u7684\u672c\u8d28 \u6307\u9488\u662f\u5b58\u50a8\u5185\u5b58\u5730\u5740\u7684\u53d8\u91cf\u3002 int a = 1; float b = 0.1; \u6307\u9488 p = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[23],"tags":[],"class_list":["post-286","post","type-post","status-publish","format-standard","hentry","category-23"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/4.189.252.43\/index.php\/wp-json\/wp\/v2\/posts\/286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/4.189.252.43\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4.189.252.43\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4.189.252.43\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4.189.252.43\/index.php\/wp-json\/wp\/v2\/comments?post=286"}],"version-history":[{"count":1,"href":"http:\/\/4.189.252.43\/index.php\/wp-json\/wp\/v2\/posts\/286\/revisions"}],"predecessor-version":[{"id":287,"href":"http:\/\/4.189.252.43\/index.php\/wp-json\/wp\/v2\/posts\/286\/revisions\/287"}],"wp:attachment":[{"href":"http:\/\/4.189.252.43\/index.php\/wp-json\/wp\/v2\/media?parent=286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4.189.252.43\/index.php\/wp-json\/wp\/v2\/categories?post=286"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4.189.252.43\/index.php\/wp-json\/wp\/v2\/tags?post=286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}