{"id":648,"date":"2009-09-23T19:27:00","date_gmt":"2009-09-23T11:27:00","guid":{"rendered":""},"modified":"2013-11-24T20:52:21","modified_gmt":"2013-11-24T12:52:21","slug":"%e6%b7%b1%e5%85%a5%e7%90%86%e8%a7%a3c%e8%af%ad%e8%a8%80%e6%8c%87%e9%92%88%e7%9a%84%e5%a5%a5%e7%a7%98","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/648.html","title":{"rendered":"\u6df1\u5165\u7406\u89e3C\u8bed\u8a00\u6307\u9488\u7684\u5965\u79d8"},"content":{"rendered":"<p>\u6307\u9488\u662f\u4e00\u4e2a\u7279\u6b8a\u7684\u53d8\u91cf\uff0c\u5b83\u91cc\u9762\u5b58\u50a8\u7684\u6570\u503c\u88ab\u89e3\u91ca\u6210\u4e3a\u5185\u5b58\u91cc\u7684\u4e00\u4e2a\u5730\u5740\u3002 \u8981\u641e\u6e05\u4e00\u4e2a\u6307\u9488\u9700\u8981\u641e\u6e05\u6307\u9488\u7684\u56db\u65b9\u9762\u7684\u5185\u5bb9\uff1a\u6307\u9488\u7684\u7c7b\u578b\uff0c\u6307\u9488\u6240\u6307\u5411\u7684 \u7c7b\u578b\uff0c\u6307\u9488\u7684\u503c\u6216\u8005\u53eb\u6307\u9488\u6240\u6307\u5411\u7684\u5185\u5b58\u533a\uff0c\u8fd8\u6709\u6307\u9488\u672c\u8eab\u6240\u5360\u636e\u7684\u5185\u5b58\u533a\u3002\u8ba9\u6211\u4eec\u5206\u522b\u8bf4\u660e\u3002<br \/>\n\u5148\u58f0\u660e\u51e0\u4e2a\u6307\u9488\u653e\u7740\u505a\u4f8b\u5b50\uff1a<br \/>\n\u4f8b\u4e00\uff1a<br \/>\n(1)int*ptr;<br \/>\n(2)char*ptr;<br \/>\n(3)int**ptr;<br \/>\n(4)int(*ptr)[3];<br \/>\n(5)int*(*ptr)[4];<\/p>\n<p>\u6307\u9488\u7684\u7c7b\u578b<br \/>\n\u4ece\u8bed\u6cd5\u7684\u89d2\u5ea6\u770b\uff0c\u4f60\u53ea\u8981\u628a\u6307\u9488\u58f0\u660e\u8bed\u53e5\u91cc\u7684\u6307\u9488\u540d\u5b57\u53bb\u6389\uff0c\u5269\u4e0b\u7684\u90e8\u5206\u5c31\u662f\u8fd9\u4e2a\u6307\u9488\u7684\u7c7b\u578b\u3002\u8fd9\u662f\u6307\u9488\u672c\u8eab\u6240\u5177\u6709\u7684\u7c7b\u578b\u3002\u8ba9\u6211\u4eec\u770b\u770b\u4f8b\u4e00\u4e2d\u5404\u4e2a\u6307\u9488\u7684\u7c7b\u578b\uff1a<br \/>\n(1)int*ptr;\/\/\u6307\u9488\u7684\u7c7b\u578b\u662fint*<br \/>\n(2)char*ptr;\/\/\u6307\u9488\u7684\u7c7b\u578b\u662fchar*<br \/>\n(3)int**ptr;\/\/\u6307\u9488\u7684\u7c7b\u578b\u662fint**<br \/>\n(4)int(*ptr)[3];\/\/\u6307\u9488\u7684\u7c7b\u578b\u662fint(*)[3]<br \/>\n(5)int*(*ptr)[4];\/\/\u6307\u9488\u7684\u7c7b\u578b\u662fint*(*)[4]<br \/>\n\u600e\u4e48\u6837\uff1f\u627e\u51fa\u6307\u9488\u7684\u7c7b\u578b\u7684\u65b9\u6cd5\u662f\u4e0d\u662f\u5f88\u7b80\u5355\uff1f<br \/>\n\u6307\u9488\u6240\u6307\u5411\u7684\u7c7b\u578b<br \/>\n\u5f53\u4f60\u901a\u8fc7\u6307\u9488\u6765\u8bbf\u95ee\u6307\u9488\u6240\u6307\u5411\u7684\u5185\u5b58\u533a\u65f6\uff0c\u6307\u9488\u6240\u6307\u5411\u7684\u7c7b\u578b\u51b3\u5b9a\u4e86\u7f16\u8bd1\u5668\u5c06\u628a\u90a3\u7247\u5185\u5b58\u533a\u91cc\u7684\u5185\u5bb9\u5f53\u505a\u4ec0\u4e48\u6765\u770b\u5f85\u3002<br \/>\n\u4ece\u8bed\u6cd5\u4e0a\u770b\uff0c\u4f60\u53ea\u987b\u628a\u6307\u9488\u58f0\u660e\u8bed\u53e5\u4e2d\u7684\u6307\u9488\u540d\u5b57\u548c\u540d\u5b57\u5de6\u8fb9\u7684\u6307\u9488\u58f0\u660e\u7b26*\u53bb\u6389\uff0c\u5269\u4e0b\u7684\u5c31\u662f\u6307\u9488\u6240\u6307\u5411\u7684\u7c7b\u578b\u3002\u4f8b\u5982\uff1a<br \/>\n(1)int*ptr;\/\/\u6307\u9488\u6240\u6307\u5411\u7684\u7c7b\u578b\u662fint<br \/>\n(2)char*ptr;\/\/\u6307\u9488\u6240\u6307\u5411\u7684\u7684\u7c7b\u578b\u662fchar<br \/>\n(3)int**ptr;\/\/\u6307\u9488\u6240\u6307\u5411\u7684\u7684\u7c7b\u578b\u662fint*<br \/>\n(4)int(*ptr)[3];\/\/\u6307\u9488\u6240\u6307\u5411\u7684\u7684\u7c7b\u578b\u662fint()[3]<br \/>\n(5)int*(*ptr)[4];\/\/\u6307\u9488\u6240\u6307\u5411\u7684\u7684\u7c7b\u578b\u662fint*()[4]<br \/>\n\u5728\u6307\u9488\u7684\u7b97\u672f\u8fd0\u7b97\u4e2d\uff0c\u6307\u9488\u6240\u6307\u5411\u7684\u7c7b\u578b\u6709\u5f88\u5927\u7684\u4f5c\u7528\u3002<br \/>\n\u6307\u9488\u7684\u7c7b\u578b(\u5373\u6307\u9488\u672c\u8eab\u7684\u7c7b\u578b)\u548c\u6307\u9488\u6240\u6307\u5411\u7684\u7c7b\u578b\u662f\u4e24\u4e2a\u6982\u5ff5\u3002\u5f53\u4f60\u5bf9C\u8d8a\u6765\u8d8a\u719f\u6089\u65f6\uff0c\u4f60\u4f1a\u53d1\u73b0\uff0c\u628a\u4e0e\u6307\u9488\u6405\u548c\u5728\u4e00\u8d77\u7684 &#8220;\u7c7b\u578b &#8220;\u8fd9\u4e2a\u6982\u5ff5\u5206\u6210 &#8220;\u6307\u9488\u7684\u7c7b\u578b &#8220;\u548c &#8220;\u6307\u9488\u6240\u6307\u5411\u7684\u7c7b\u578b &#8220;\u4e24\u4e2a\u6982\u5ff5\uff0c\u662f\u7cbe\u901a\u6307\u9488\u7684\u5173\u952e\u70b9\u4e4b\u4e00\u3002\u6211\u770b\u4e86\u4e0d\u5c11\u4e66\uff0c\u53d1\u73b0\u6709\u4e9b\u5199\u5f97\u5dee\u7684\u4e66\u4e2d\uff0c\u5c31\u628a\u6307\u9488\u7684\u8fd9\u4e24\u4e2a\u6982\u5ff5\u6405\u5728\u4e00\u8d77\u4e86\uff0c\u6240\u4ee5\u770b\u8d77\u4e66\u6765\u524d\u540e\u77db\u76fe\uff0c\u8d8a\u770b\u8d8a\u7cca\u6d82\u3002<br \/>\n\u6307\u9488\u7684\u503c\uff0c\u6216\u8005\u53eb\u6307\u9488\u6240\u6307\u5411\u7684\u5185\u5b58\u533a\u6216\u5730\u5740<br \/>\n\u6307\u9488\u7684\u503c\u662f\u6307\u9488\u672c\u8eab\u5b58\u50a8\u7684\u6570\u503c\uff0c\u8fd9\u4e2a\u503c\u5c06\u88ab\u7f16\u8bd1\u5668\u5f53\u4f5c\u4e00\u4e2a\u5730\u5740\uff0c\u800c\u4e0d\u662f\u4e00\u4e2a\u4e00\u822c\u7684\u6570\u503c\u3002\u572832\u4f4d\u7a0b\u5e8f\u91cc\uff0c\u6240\u6709\u7c7b\u578b\u7684\u6307\u9488\u7684\u503c\u90fd\u662f\u4e00\u4e2a32\u4f4d\u6574\u6570\uff0c\u56e0\u4e3a 32\u4f4d\u7a0b\u5e8f\u91cc\u5185\u5b58\u5730\u5740\u5168\u90fd\u662f32\u4f4d\u957f\u3002 \u6307\u9488\u6240\u6307\u5411\u7684\u5185\u5b58\u533a\u5c31\u662f\u4ece\u6307\u9488\u7684\u503c\u6240\u4ee3\u8868\u7684\u90a3\u4e2a\u5185\u5b58\u5730\u5740\u5f00\u59cb\uff0c\u957f\u5ea6\u4e3asi zeof(\u6307\u9488\u6240\u6307\u5411\u7684\u7c7b\u578b)\u7684\u4e00\u7247\u5185\u5b58\u533a\u3002\u4ee5\u540e\uff0c\u6211\u4eec\u8bf4\u4e00\u4e2a\u6307\u9488\u7684\u503c\u662fXX\uff0c\u5c31\u76f8\u5f53\u4e8e\u8bf4\u8be5\u6307\u9488\u6307\u5411\u4e86\u4ee5XX\u4e3a\u9996\u5730\u5740\u7684\u4e00\u7247\u5185\u5b58\u533a\u57df\uff1b\u6211\u4eec\u8bf4\u4e00\u4e2a\u6307\u9488\u6307\u5411 \u4e86\u67d0\u5757\u5185\u5b58\u533a\u57df\uff0c\u5c31\u76f8\u5f53\u4e8e\u8bf4\u8be5\u6307\u9488\u7684\u503c\u662f\u8fd9\u5757\u5185\u5b58\u533a\u57df\u7684\u9996\u5730\u5740\u3002<br \/>\n\u6307\u9488\u6240\u6307\u5411\u7684\u5185\u5b58\u533a\u548c\u6307\u9488\u6240\u6307\u5411\u7684\u7c7b\u578b\u662f\u4e24\u4e2a\u5b8c\u5168\u4e0d\u540c\u7684\u6982\u5ff5\u3002\u5728\u4f8b\u4e00\u4e2d\uff0c\u6307\u9488\u6240\u6307\u5411\u7684\u7c7b\u578b\u5df2\u7ecf\u6709\u4e86\uff0c\u4f46\u7531\u4e8e\u6307\u9488\u8fd8\u672a\u521d\u59cb\u5316\uff0c\u6240\u4ee5\u5b83\u6240\u6307\u5411\u7684\u5185\u5b58\u533a\u662f\u4e0d\u5b58\u5728\u7684\uff0c\u6216\u8005\u8bf4\u662f\u65e0\u610f\u4e49\u7684\u3002<br \/>\n\u4ee5\u540e\uff0c\u6bcf\u9047\u5230\u4e00\u4e2a\u6307\u9488\uff0c\u90fd\u5e94\u8be5\u95ee\u95ee\uff1a\u8fd9\u4e2a\u6307\u9488\u7684\u7c7b\u578b\u662f\u4ec0\u4e48\uff1f\u6307\u9488\u6307\u7684\u7c7b\u578b\u662f\u4ec0\u4e48\uff1f\u8be5\u6307\u9488\u6307\u5411\u4e86\u54ea\u91cc\uff1f<br \/>\n\u6307\u9488\u672c\u8eab\u6240\u5360\u636e\u7684\u5185\u5b58\u533a<br \/>\n\u6307\u9488\u672c\u8eab\u5360\u4e86\u591a\u5927\u7684\u5185\u5b58\uff1f\u4f60\u53ea\u8981\u7528\u51fd\u6570sizeof(\u6307\u9488\u7684\u7c7b\u578b)\u6d4b\u4e00\u4e0b\u5c31\u77e5\u9053\u4e86\u3002\u572832\u4f4d\u5e73\u53f0\u91cc\uff0c\u6307\u9488\u672c\u8eab\u5360\u636e\u4e864\u4e2a\u5b57\u8282\u7684\u957f\u5ea6\u3002<br \/>\n\u6307\u9488\u672c\u8eab\u5360\u636e\u7684\u5185\u5b58\u8fd9\u4e2a\u6982\u5ff5\u5728\u5224\u65ad\u4e00\u4e2a\u6307\u9488\u8868\u8fbe\u5f0f\u662f\u5426\u662f\u5de6\u503c\u65f6\u5f88\u6709\u7528\u3002<br \/>\n\u6307\u9488\u7684\u7b97\u672f\u8fd0\u7b97<br \/>\n\u6307\u9488\u53ef\u4ee5\u52a0\u4e0a\u6216\u51cf\u53bb\u4e00\u4e2a\u6574\u6570\u3002\u6307\u9488\u7684\u8fd9\u79cd\u8fd0\u7b97\u7684\u610f\u4e49\u548c\u901a\u5e38\u7684\u6570\u503c\u7684\u52a0\u51cf\u8fd0\u7b97\u7684\u610f\u4e49\u662f\u4e0d\u4e00\u6837\u7684\u3002\u4f8b\u5982\uff1a<br \/>\n\u4f8b\u4e8c\uff1a<br \/>\n1\u3001chara[20];<br \/>\n2\u3001int*ptr=a;<br \/>\n&#8230;<br \/>\n&#8230;<br \/>\n3\u3001ptr++;<br \/>\n\u5728\u4e0a\u4f8b\u4e2d\uff0c\u6307\u9488ptr\u7684\u7c7b\u578b\u662fint*,\u5b83\u6307\u5411\u7684\u7c7b\u578b\u662fint\uff0c\u5b83\u88ab\u521d\u59cb\u5316\u4e3a\u6307\u5411\u6574\u5f62\u53d8\u91cfa\u3002\u63a5\u4e0b\u6765\u7684\u7b2c3\u53e5\u4e2d\uff0c\u6307\u9488ptr\u88ab\u52a0\u4e861\uff0c\u7f16\u8bd1\u5668\u662f\u8fd9\u6837\u5904 \u7406\u7684\uff1a\u5b83\u628a\u6307\u9488ptr\u7684\u503c\u52a0\u4e0a\u4e86sizeof(int)\uff0c\u572832\u4f4d\u7a0b\u5e8f\u4e2d\uff0c\u662f\u88ab\u52a0\u4e0a\u4e864\u3002\u7531\u4e8e\u5730\u5740\u662f\u7528\u5b57\u8282\u505a\u5355\u4f4d\u7684\uff0c\u6545ptr\u6240\u6307\u5411\u7684\u5730\u5740\u7531\u539f\u6765\u7684\u53d8\u91cfa \u7684\u5730\u5740\u5411\u9ad8\u5730\u5740\u65b9\u5411\u589e\u52a0\u4e864\u4e2a\u5b57\u8282\u3002<br \/>\n\u7531\u4e8echar\u7c7b\u578b\u7684\u957f\u5ea6\u662f\u4e00\u4e2a\u5b57\u8282\uff0c\u6240\u4ee5\uff0c\u539f\u6765ptr\u662f\u6307\u5411\u6570\u7ec4a\u7684\u7b2c0\u53f7\u5355\u5143\u5f00\u59cb\u7684\u56db\u4e2a\u5b57\u8282\uff0c\u6b64\u65f6\u6307\u5411\u4e86\u6570\u7ec4a\u4e2d\u4ece\u7b2c4\u53f7\u5355\u5143\u5f00\u59cb\u7684\u56db\u4e2a\u5b57\u8282\u3002<br \/>\n\u6211\u4eec\u53ef\u4ee5\u7528\u4e00\u4e2a\u6307\u9488\u548c\u4e00\u4e2a\u5faa\u73af\u6765\u904d\u5386\u4e00\u4e2a\u6570\u7ec4\uff0c\u770b\u4f8b\u5b50\uff1a<br \/>\n\u4f8b\u4e09\uff1a<br \/>\nintarray[20];<br \/>\nint*ptr=array;<br \/>\n&#8230;<br \/>\n\/\/\u6b64\u5904\u7565\u53bb\u4e3a\u6574\u578b\u6570\u7ec4\u8d4b\u503c\u7684\u4ee3\u7801\u3002<br \/>\n&#8230;<br \/>\nfor(i=0;i &lt;20;i++)<br \/>\n{<br \/>\n(*ptr)++;<br \/>\nptr++\uff1b<br \/>\n}<br \/>\n\u8fd9\u4e2a\u4f8b\u5b50\u5c06\u6574\u578b\u6570\u7ec4\u4e2d\u5404\u4e2a\u5355\u5143\u7684\u503c\u52a01\u3002\u7531\u4e8e\u6bcf\u6b21\u5faa\u73af\u90fd\u5c06\u6307\u9488ptr\u52a01\uff0c\u6240\u4ee5\u6bcf\u6b21\u5faa\u73af\u90fd\u80fd\u8bbf\u95ee\u6570\u7ec4\u7684\u4e0b\u4e00\u4e2a\u5355\u5143\u3002<\/p>\n<p>\u518d\u770b\u4f8b\u5b50\uff1a<\/p>\n<p>\u4f8b\u56db\uff1a<\/p>\n<p>1\u3001chara[20];<br \/>\n2\u3001int*ptr=a;<br \/>\n&#8230;<br \/>\n&#8230;<br \/>\n3\u3001ptr+=5;<br \/>\n\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cptr\u88ab\u52a0\u4e0a\u4e865\uff0c\u7f16\u8bd1\u5668\u662f\u8fd9\u6837\u5904\u7406\u7684\uff1a\u5c06\u6307\u9488ptr\u7684\u503c\u52a0\u4e0a5\u4e58sizeof(int)\uff0c\u572832\u4f4d\u7a0b\u5e8f\u4e2d\u5c31\u662f\u52a0\u4e0a\u4e865\u4e584=20\u3002\u7531 \u4e8e\u5730\u5740\u7684\u5355\u4f4d\u662f\u5b57\u8282\uff0c\u6545\u73b0\u5728\u7684ptr\u6240\u6307\u5411\u7684\u5730\u5740\u6bd4\u8d77\u52a05\u540e\u7684ptr\u6240\u6307\u5411\u7684\u5730\u5740\u6765\u8bf4\uff0c\u5411\u9ad8\u5730\u5740\u65b9\u5411\u79fb\u52a8\u4e8620\u4e2a\u5b57\u8282\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6ca1\u52a05\u524d\u7684ptr\u6307 \u5411\u6570\u7ec4a\u7684\u7b2c0\u53f7\u5355\u5143\u5f00\u59cb\u7684\u56db\u4e2a\u5b57\u8282\uff0c\u52a05\u540e\uff0cptr\u5df2\u7ecf\u6307\u5411\u4e86\u6570\u7ec4a\u7684\u5408\u6cd5\u8303\u56f4\u4e4b\u5916\u4e86\u3002\u867d\u7136\u8fd9\u79cd\u60c5\u51b5\u5728\u5e94\u7528\u4e0a\u4f1a\u51fa\u95ee\u9898\uff0c\u4f46\u5728\u8bed\u6cd5\u4e0a\u5374\u662f\u53ef\u4ee5\u7684\u3002\u8fd9\u4e5f\u4f53\u73b0 \u51fa\u4e86\u6307\u9488\u7684\u7075\u6d3b\u6027\u3002<br \/>\n\u5982\u679c\u4e0a\u4f8b\u4e2d\uff0cptr\u662f\u88ab\u51cf\u53bb5\uff0c\u90a3\u4e48\u5904\u7406\u8fc7\u7a0b\u5927\u540c\u5c0f\u5f02\uff0c\u53ea\u4e0d\u8fc7ptr\u7684\u503c\u662f\u88ab\u51cf\u53bb5\u4e58sizeof(int)\uff0c\u65b0\u7684ptr\u6307\u5411\u7684\u5730\u5740\u5c06\u6bd4\u539f\u6765\u7684ptr\u6240\u6307\u5411\u7684\u5730\u5740\u5411\u4f4e\u5730\u5740\u65b9\u5411\u79fb\u52a8\u4e8620\u4e2a\u5b57\u8282\u3002<br \/>\n\u603b\u7ed3\u4e00\u4e0b\uff0c\u4e00\u4e2a\u6307\u9488ptrold\u52a0\u4e0a\u4e00\u4e2a\u6574\u6570n\u540e\uff0c\u7ed3\u679c\u662f\u4e00\u4e2a\u65b0\u7684\u6307\u9488ptrnew\uff0cptrnew\u7684\u7c7b\u578b\u548cptrold\u7684\u7c7b\u578b\u76f8\u540c\uff0cptrnew\u6240\u6307 \u5411\u7684\u7c7b\u578b\u548cptrold\u6240\u6307\u5411\u7684\u7c7b\u578b\u4e5f\u76f8\u540c\u3002ptrnew\u7684\u503c\u5c06\u6bd4ptrold\u7684\u503c\u589e\u52a0\u4e86n\u4e58sizeof(ptrold\u6240\u6307\u5411\u7684\u7c7b\u578b)\u4e2a\u5b57\u8282\u3002\u5c31\u662f \u8bf4\uff0cptrnew\u6240\u6307\u5411\u7684\u5185\u5b58\u533a\u5c06\u6bd4ptrold\u6240\u6307\u5411\u7684\u5185\u5b58\u533a\u5411\u9ad8\u5730\u5740\u65b9\u5411\u79fb\u52a8\u4e86n\u4e58sizeof(ptrold\u6240\u6307\u5411\u7684\u7c7b\u578b)\u4e2a\u5b57\u8282\u3002<br \/>\n\u4e00\u4e2a\u6307\u9488ptrold\u51cf\u53bb\u4e00\u4e2a\u6574\u6570n\u540e\uff0c\u7ed3\u679c\u662f\u4e00\u4e2a\u65b0\u7684\u6307\u9488ptrnew\uff0cptrnew\u7684\u7c7b\u578b\u548cptrold\u7684\u7c7b\u578b\u76f8\u540c\uff0cptrnew\u6240\u6307\u5411\u7684\u7c7b\u578b\u548c ptrold\u6240\u6307\u5411\u7684\u7c7b\u578b\u4e5f\u76f8\u540c\u3002ptrnew\u7684\u503c\u5c06\u6bd4ptrold\u7684\u503c\u51cf\u5c11\u4e86n\u4e58sizeof(ptrold\u6240\u6307\u5411\u7684\u7c7b\u578b)\u4e2a\u5b57\u8282\uff0c\u5c31\u662f \u8bf4\uff0cptrnew\u6240\u6307\u5411\u7684\u5185\u5b58\u533a\u5c06\u6bd4ptrold\u6240\u6307\u5411\u7684\u5185\u5b58\u533a\u5411\u4f4e\u5730\u5740\u65b9\u5411\u79fb\u52a8\u4e86n\u4e58sizeof(ptrold\u6240\u6307\u5411\u7684\u7c7b\u578b)\u4e2a\u5b57\u8282\u3002<br \/>\n\u8fd0\u7b97\u7b26&amp;\u548c*<br \/>\n\u8fd9\u91cc&amp;\u662f\u53d6\u5730\u5740\u8fd0\u7b97\u7b26\uff0c*\u662f&#8230;\u4e66\u4e0a\u53eb\u505a &#8220;\u95f4\u63a5\u8fd0\u7b97\u7b26 &#8220;\u3002<br \/>\n&amp;a\u7684\u8fd0\u7b97\u7ed3\u679c\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u6307\u9488\u7684\u7c7b\u578b\u662fa\u7684\u7c7b\u578b\u52a0\u4e2a*\uff0c\u6307\u9488\u6240\u6307\u5411\u7684\u7c7b\u578b\u662fa\u7684\u7c7b\u578b\uff0c\u6307\u9488\u6240\u6307\u5411\u7684\u5730\u5740\u561b\uff0c\u90a3\u5c31\u662fa\u7684\u5730\u5740\u3002<br \/>\n*p\u7684\u8fd0\u7b97\u7ed3\u679c\u5c31\u4e94\u82b1\u516b\u95e8\u4e86\u3002\u603b\u4e4b*p\u7684\u7ed3\u679c\u662fp\u6240\u6307\u5411\u7684\u4e1c\u897f\uff0c\u8fd9\u4e2a\u4e1c\u897f\u6709\u8fd9\u4e9b\u7279\u70b9\uff1a\u5b83\u7684\u7c7b\u578b\u662fp\u6307\u5411\u7684\u7c7b\u578b\uff0c\u5b83\u6240\u5360\u7528\u7684\u5730\u5740\u662fp\u6240\u6307\u5411\u7684\u5730\u5740\u3002<br \/>\n\u4f8b\u4e94\uff1a<br \/>\ninta=12;<br \/>\nintb;<br \/>\nint*p;<br \/>\nint**ptr;<br \/>\np=&amp;a;<br \/>\n\/\/&amp;a\u7684\u7ed3\u679c\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u7c7b\u578b\u662fint*\uff0c\u6307\u5411\u7684\u7c7b\u578b\u662fint\uff0c\u6307\u5411\u7684\u5730\u5740\u662fa\u7684\u5730\u5740\u3002<br \/>\n*p=24;<br \/>\n\/\/*p\u7684\u7ed3\u679c\uff0c\u5728\u8fd9\u91cc\u5b83\u7684\u7c7b\u578b\u662fint\uff0c\u5b83\u6240\u5360\u7528\u7684\u5730\u5740\u662fp\u6240\u6307\u5411\u7684\u5730\u5740\uff0c\u663e\u7136\uff0c*p\u5c31\u662f\u53d8\u91cfa\u3002<br \/>\nptr=&amp;p;<br \/>\n\/\/&amp;p\u7684\u7ed3\u679c\u662f\u4e2a\u6307\u9488\uff0c\u8be5\u6307\u9488\u7684\u7c7b\u578b\u662fp\u7684\u7c7b\u578b\u52a0\u4e2a*\uff0c\u5728\u8fd9\u91cc\u662fint **\u3002\u8be5\u6307\u9488\u6240\u6307\u5411\u7684\u7c7b\u578b\u662fp\u7684\u7c7b\u578b\uff0c\u8fd9\u91cc\u662fint*\u3002\u8be5\u6307\u9488\u6240\u6307\u5411\u7684\u5730\u5740\u5c31\u662f\u6307\u9488p\u81ea\u5df1\u7684\u5730\u5740\u3002<br \/>\n*ptr=&amp;b;<br \/>\n\/\/*ptr\u662f\u4e2a\u6307\u9488\uff0c&amp;b\u7684\u7ed3\u679c\u4e5f\u662f\u4e2a\u6307\u9488\uff0c\u4e14\u8fd9\u4e24\u4e2a\u6307\u9488\u7684\u7c7b\u578b\u548c\u6240\u6307\u5411\u7684\u7c7b\u578b\u662f\u4e00\u6837\u7684\uff0c\u6240\u4ee5\u7528&amp;b\u6765\u7ed9*ptr\u8d4b\u503c\u5c31\u662f\u6beb\u65e0\u95ee\u9898\u7684\u4e86\u3002<br \/>\n**ptr=34;<br \/>\n\/\/*ptr\u7684\u7ed3\u679c\u662fptr\u6240\u6307\u5411\u7684\u4e1c\u897f\uff0c\u5728\u8fd9\u91cc\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u5bf9\u8fd9\u4e2a\u6307\u9488\u518d\u505a\u4e00\u6b21*\u8fd0\u7b97\uff0c\u7ed3\u679c\u5c31\u662f\u4e00\u4e2aint\u7c7b\u578b\u7684\u53d8\u91cf\u3002<br \/>\n\u6307\u9488\u8868\u8fbe\u5f0f<br \/>\n\u4e00\u4e2a\u8868\u8fbe\u5f0f\u7684\u6700\u540e\u7ed3\u679c\u5982\u679c\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u90a3\u4e48\u8fd9\u4e2a\u8868\u8fbe\u5f0f\u5c31\u53eb\u6307\u9488\u8868\u5f0f\u3002<br \/>\n\u4e0b\u9762\u662f\u4e00\u4e9b\u6307\u9488\u8868\u8fbe\u5f0f\u7684\u4f8b\u5b50\uff1a<br \/>\n\u4f8b\u516d\uff1a<br \/>\ninta,b;<br \/>\nintarray[10];<br \/>\nint*pa;<br \/>\npa=&amp;a;\/\/&amp;a\u662f\u4e00\u4e2a\u6307\u9488\u8868\u8fbe\u5f0f\u3002<br \/>\nint**ptr=&amp;pa;\/\/&amp;pa\u4e5f\u662f\u4e00\u4e2a\u6307\u9488\u8868\u8fbe\u5f0f\u3002<br \/>\n*ptr=&amp;b;\/\/*ptr\u548c&amp;b\u90fd\u662f\u6307\u9488\u8868\u8fbe\u5f0f\u3002<br \/>\npa=array;<br \/>\npa++;\/\/\u8fd9\u4e5f\u662f\u6307\u9488\u8868\u8fbe\u5f0f\u3002<br \/>\n\u4f8b\u4e03\uff1a<br \/>\nchar*arr[20];<br \/>\nchar**parr=arr;\/\/\u5982\u679c\u628aarr\u770b\u4f5c\u6307\u9488\u7684\u8bdd\uff0carr\u4e5f\u662f\u6307\u9488\u8868\u8fbe\u5f0f<br \/>\nchar*str;<br \/>\nstr=*parr;\/\/*parr\u662f\u6307\u9488\u8868\u8fbe\u5f0f<br \/>\nstr=*(parr+1);\/\/*(parr+1)\u662f\u6307\u9488\u8868\u8fbe\u5f0f<br \/>\nstr=*(parr+2);\/\/*(parr+2)\u662f\u6307\u9488\u8868\u8fbe\u5f0f<br \/>\n\u7531\u4e8e\u6307\u9488\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u6240\u4ee5\u6307\u9488\u8868\u8fbe\u5f0f\u4e5f\u5177\u6709\u6307\u9488\u6240\u5177\u6709\u7684\u56db\u4e2a\u8981\u7d20\uff1a\u6307\u9488\u7684\u7c7b\u578b\uff0c\u6307\u9488\u6240\u6307\u5411\u7684\u7c7b\u578b\uff0c\u6307\u9488\u6307\u5411\u7684\u5185\u5b58\u533a\uff0c\u6307\u9488\u81ea\u8eab\u5360\u636e\u7684\u5185\u5b58\u3002<\/p>\n<p>\u597d\u4e86\uff0c\u5f53\u4e00\u4e2a\u6307\u9488\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\u6307\u9488\u5df2\u7ecf\u660e\u786e\u5730\u5177\u6709\u4e86\u6307\u9488\u81ea\u8eab\u5360\u636e\u7684\u5185\u5b58\u7684\u8bdd\uff0c\u8fd9\u4e2a\u6307\u9488\u8868\u8fbe\u5f0f\u5c31\u662f\u4e00\u4e2a\u5de6\u503c\uff0c\u5426\u5219\u5c31\u4e0d\u662f\u4e00\u4e2a\u5de6\u503c\u3002<br \/>\n\u5728\u4f8b\u4e03\u4e2d\uff0c&amp;a\u4e0d\u662f\u4e00\u4e2a\u5de6\u503c\uff0c\u56e0\u4e3a\u5b83\u8fd8\u6ca1\u6709\u5360\u636e\u660e\u786e\u7684\u5185\u5b58\u3002*ptr\u662f\u4e00\u4e2a\u5de6\u503c\uff0c\u56e0\u4e3a*ptr\u8fd9\u4e2a\u6307\u9488\u5df2\u7ecf\u5360\u636e\u4e86\u5185\u5b58\uff0c\u5176\u5b9e*ptr\u5c31\u662f\u6307\u9488pa\uff0c\u65e2\u7136pa\u5df2\u7ecf\u5728\u5185\u5b58\u4e2d\u6709\u4e86\u81ea\u5df1\u7684\u4f4d\u7f6e\uff0c\u90a3\u4e48*ptr\u5f53\u7136\u4e5f\u6709\u4e86\u81ea\u5df1\u7684\u4f4d\u7f6e\u3002<br \/>\n\u6570\u7ec4\u548c\u6307\u9488\u7684\u5173\u7cfb<br \/>\n\u6570\u7ec4\u7684\u6570\u7ec4\u540d\u5176\u5b9e\u53ef\u4ee5\u770b\u4f5c\u4e00\u4e2a\u6307\u9488\u3002\u770b\u4e0b\u4f8b\uff1a<br \/>\n\u4f8b\u516b\uff1a<br \/>\nintarray[10]={0,1,2,3,4,5,6,7,8,9},value;<br \/>\n&#8230;<br \/>\n&#8230;<br \/>\nvalue=array[0];\/\/\u4e5f\u53ef\u5199\u6210\uff1avalue=*array;<br \/>\nvalue=array[3];\/\/\u4e5f\u53ef\u5199\u6210\uff1avalue=*(array+3);<br \/>\nvalue=array[4];\/\/\u4e5f\u53ef\u5199\u6210\uff1avalue=*(array+4);<br \/>\n\u4e0a\u4f8b\u4e2d\uff0c\u4e00\u822c\u800c\u8a00\u6570\u7ec4\u540darray\u4ee3\u8868\u6570\u7ec4\u672c\u8eab\uff0c\u7c7b\u578b\u662fint[10]\uff0c\u4f46\u5982\u679c\u628aarray\u770b\u505a\u6307\u9488\u7684\u8bdd\uff0c\u5b83\u6307\u5411\u6570\u7ec4\u7684\u7b2c0\u4e2a\u5355\u5143\uff0c\u7c7b\u578b\u662fint*\uff0c\u6240\u6307 \u5411\u7684\u7c7b\u578b\u662f\u6570\u7ec4\u5355\u5143\u7684\u7c7b\u578b\u5373int\u3002\u56e0\u6b64*array\u7b49\u4e8e0\u5c31\u4e00\u70b9\u4e5f\u4e0d\u5947\u602a\u4e86\u3002\u540c\u7406\uff0carray+3\u662f\u4e00\u4e2a\u6307\u5411\u6570\u7ec4\u7b2c3\u4e2a\u5355\u5143\u7684\u6307\u9488\uff0c\u6240\u4ee5* (array+3)\u7b49\u4e8e3\u3002\u5176\u5b83\u4f9d\u6b64\u7c7b\u63a8\u3002<\/p>\n<p>\u4f8b\u4e5d\uff1a<br \/>\nchar*str[3]={<br \/>\n&#8220;Hello,thisisasample! &#8220;,<br \/>\n&#8220;Hi,goodmorning. &#8220;,<br \/>\n&#8220;Helloworld &#8221;<br \/>\n};<br \/>\nchars[80]\uff1b<br \/>\nstrcpy(s,str[0]);\/\/\u4e5f\u53ef\u5199\u6210strcpy(s,*str);<br \/>\nstrcpy(s,str[1]);\/\/\u4e5f\u53ef\u5199\u6210strcpy(s,*(str+1));<br \/>\nstrcpy(s,str[2]);\/\/\u4e5f\u53ef\u5199\u6210strcpy(s,*(str+2));<br \/>\n\u4e0a\u4f8b\u4e2d\uff0cstr\u662f\u4e00\u4e2a\u4e09\u5355\u5143\u7684\u6570\u7ec4\uff0c\u8be5\u6570\u7ec4\u7684\u6bcf\u4e2a\u5355\u5143\u90fd\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u8fd9\u4e9b\u6307\u9488\u5404\u6307\u5411\u4e00\u4e2a\u5b57\u7b26\u4e32\u3002\u628a\u6307\u9488\u6570\u7ec4\u540dstr\u5f53\u4f5c\u4e00\u4e2a\u6307\u9488\u7684\u8bdd\uff0c\u5b83\u6307\u5411\u6570\u7ec4\u7684\u7b2c0\u53f7\u5355\u5143\uff0c\u5b83\u7684\u7c7b\u578b\u662fchar**\uff0c\u5b83\u6307\u5411\u7684\u7c7b\u578b\u662fchar*\u3002<br \/>\n*str\u4e5f\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u5b83\u7684\u7c7b\u578b\u662fchar*\uff0c\u5b83\u6240\u6307\u5411\u7684\u7c7b\u578b\u662fchar\uff0c\u5b83\u6307\u5411\u7684\u5730\u5740\u662f\u5b57\u7b26\u4e32 &#8220;Hello,thisisasample! &#8220;\u7684\u7b2c\u4e00\u4e2a\u5b57\u7b26\u7684\u5730\u5740\uff0c\u5373 &#8216;H &#8216;\u7684\u5730\u5740\u3002 str+1\u4e5f\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u5b83\u6307\u5411\u6570\u7ec4\u7684\u7b2c1\u53f7\u5355\u5143\uff0c\u5b83\u7684\u7c7b\u578b\u662fchar**\uff0c\u5b83\u6307\u5411\u7684\u7c7b\u578b\u662fchar*\u3002<\/p>\n<p>*(str+1)\u4e5f\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u5b83\u7684\u7c7b\u578b\u662fchar*\uff0c\u5b83\u6240\u6307\u5411\u7684\u7c7b\u578b\u662fchar\uff0c\u5b83\u6307\u5411 &#8220;Hi,goodmorning. &#8220;\u7684\u7b2c\u4e00\u4e2a\u5b57\u7b26 &#8216;H &#8216;\uff0c\u7b49\u7b49\u3002<\/p>\n<p>\u4e0b\u9762\u603b\u7ed3\u4e00\u4e0b\u6570\u7ec4\u7684\u6570\u7ec4\u540d\u7684\u95ee\u9898\u3002\u58f0\u660e\u4e86\u4e00\u4e2a\u6570\u7ec4TYPEarray[n]\uff0c\u5219\u6570\u7ec4\u540d\u79f0array\u5c31\u6709\u4e86\u4e24\u91cd\u542b\u4e49\uff1a\u7b2c\u4e00\uff0c\u5b83\u4ee3\u8868\u6574\u4e2a\u6570\u7ec4\uff0c\u5b83\u7684\u7c7b\u578b\u662f TYPE[n]\uff1b\u7b2c\u4e8c \uff0c\u5b83\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u8be5\u6307\u9488\u7684\u7c7b\u578b\u662fTYPE*\uff0c\u8be5\u6307\u9488\u6307\u5411\u7684\u7c7b\u578b\u662fTYPE\uff0c\u4e5f\u5c31\u662f\u6570\u7ec4\u5355\u5143\u7684\u7c7b\u578b\uff0c\u8be5\u6307\u9488\u6307\u5411\u7684\u5185\u5b58\u533a\u5c31\u662f\u6570\u7ec4\u7b2c0\u53f7\u5355\u5143\uff0c\u8be5\u6307\u9488\u81ea\u5df1\u5360\u6709 \u5355\u72ec\u7684\u5185\u5b58\u533a\uff0c\u6ce8\u610f\u5b83\u548c\u6570\u7ec4\u7b2c0\u53f7\u5355\u5143\u5360\u636e\u7684\u5185\u5b58\u533a\u662f\u4e0d\u540c\u7684\u3002\u8be5\u6307\u9488\u7684\u503c\u662f\u4e0d\u80fd\u4fee\u6539\u7684\uff0c\u5373\u7c7b\u4f3carray++\u7684\u8868\u8fbe\u5f0f\u662f\u9519\u8bef\u7684\u3002<br \/>\n\u5728\u4e0d\u540c\u7684\u8868\u8fbe\u5f0f\u4e2d\u6570\u7ec4\u540darray\u53ef\u4ee5\u626e\u6f14\u4e0d\u540c\u7684\u89d2\u8272\u3002<br \/>\n\u5728\u8868\u8fbe\u5f0fsizeof(array)\u4e2d\uff0c\u6570\u7ec4\u540darray\u4ee3\u8868\u6570\u7ec4\u672c\u8eab\uff0c\u6545\u8fd9\u65f6sizeof\u51fd\u6570\u6d4b\u51fa\u7684\u662f\u6574\u4e2a\u6570\u7ec4\u7684\u5927\u5c0f\u3002<br \/>\n\u5728\u8868\u8fbe\u5f0f*array\u4e2d\uff0carray\u626e\u6f14\u7684\u662f\u6307\u9488\uff0c\u56e0\u6b64\u8fd9\u4e2a\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\u5c31\u662f\u6570\u7ec4\u7b2c0\u53f7\u5355\u5143\u7684\u503c\u3002sizeof(*array)\u6d4b\u51fa\u7684\u662f\u6570\u7ec4\u5355\u5143\u7684\u5927\u5c0f\u3002<br \/>\n\u8868\u8fbe\u5f0farray+n\uff08\u5176\u4e2dn=0\uff0c1\uff0c2\uff0c&#8230;.\u3002\uff09\u4e2d\uff0carray\u626e\u6f14\u7684\u662f\u6307\u9488\uff0c\u6545array+n\u7684\u7ed3\u679c\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u5b83\u7684\u7c7b\u578b\u662fTYPE*\uff0c\u5b83\u6307\u5411\u7684\u7c7b\u578b\u662fTYPE\uff0c\u5b83\u6307\u5411\u6570\u7ec4\u7b2cn\u53f7\u5355\u5143\u3002\u6545sizeof(array+n)\u6d4b\u51fa\u7684\u662f\u6307\u9488\u7c7b\u578b\u7684\u5927\u5c0f\u3002<br \/>\n\u4f8b\u5341<br \/>\nintarray[10];<br \/>\nint(*ptr)[10];<br \/>\nptr=&amp;array;\uff1a<br \/>\n\u4e0a\u4f8b\u4e2dptr\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u5b83\u7684\u7c7b\u578b\u662fint(*)[10]\uff0c\u4ed6\u6307\u5411\u7684\u7c7b\u578b\u662fint[10] \uff0c\u6211\u4eec\u7528\u6574\u4e2a\u6570\u7ec4\u7684\u9996\u5730\u5740\u6765\u521d\u59cb\u5316\u5b83\u3002\u5728\u8bed\u53e5ptr=&amp;array\u4e2d\uff0carray\u4ee3\u8868\u6570\u7ec4\u672c\u8eab\u3002<\/p>\n<p>\u672c\u8282\u4e2d\u63d0\u5230\u4e86\u51fd\u6570sizeof()\uff0c\u90a3\u4e48\u6211\u6765\u95ee\u4e00\u95ee\uff0csizeof(\u6307\u9488\u540d\u79f0)\u6d4b\u51fa\u7684\u7a76\u7adf\u662f\u6307\u9488\u81ea\u8eab\u7c7b\u578b\u7684\u5927\u5c0f\u5462\u8fd8\u662f\u6307\u9488\u6240\u6307\u5411\u7684\u7c7b\u578b\u7684\u5927\u5c0f\uff1f\u7b54\u6848\u662f\u524d\u8005\u3002\u4f8b\u5982\uff1a<br \/>\nint(*ptr)[10];<br \/>\n\u5219\u572832\u4f4d\u7a0b\u5e8f\u4e2d\uff0c\u6709\uff1a<br \/>\nsizeof(int(*)[10])==4<br \/>\nsizeof(int[10])==40<br \/>\nsizeof(ptr)==4<br \/>\n\u5b9e\u9645\u4e0a\uff0csizeof(\u5bf9\u8c61)\u6d4b\u51fa\u7684\u90fd\u662f\u5bf9\u8c61\u81ea\u8eab\u7684\u7c7b\u578b\u7684\u5927\u5c0f\uff0c\u800c\u4e0d\u662f\u522b\u7684\u4ec0\u4e48\u7c7b\u578b\u7684\u5927\u5c0f\u3002<br \/>\n\u6307\u9488\u548c\u7ed3\u6784\u7c7b\u578b\u7684\u5173\u7cfb<br \/>\n\u53ef\u4ee5\u58f0\u660e\u4e00\u4e2a\u6307\u5411\u7ed3\u6784\u7c7b\u578b\u5bf9\u8c61\u7684\u6307\u9488\u3002<br \/>\n\u4f8b\u5341\u4e00\uff1a<br \/>\nstructMyStruct<br \/>\n{<br \/>\ninta;<br \/>\nintb;<br \/>\nintc;<br \/>\n}<br \/>\nMyStructss={20,30,40};<br \/>\n\/\/\u58f0\u660e\u4e86\u7ed3\u6784\u5bf9\u8c61ss\uff0c\u5e76\u628ass\u7684\u4e09\u4e2a\u6210\u5458\u521d\u59cb\u5316\u4e3a20\uff0c30\u548c40\u3002<br \/>\nMyStruct*ptr=&amp;ss;<br \/>\n\/\/\u58f0\u660e\u4e86\u4e00\u4e2a\u6307\u5411\u7ed3\u6784\u5bf9\u8c61ss\u7684\u6307\u9488\u3002\u5b83\u7684\u7c7b\u578b\u662fMyStruct*,\u5b83\u6307\u5411\u7684\u7c7b\u578b\u662fMyStruct\u3002<br \/>\nint*pstr=(int*)&amp;ss;<br \/>\n\/\/\u58f0\u660e\u4e86\u4e00\u4e2a\u6307\u5411\u7ed3\u6784\u5bf9\u8c61ss\u7684\u6307\u9488\u3002\u4f46\u662f\u5b83\u7684\u7c7b\u578b\u548c\u5b83\u6307\u5411\u7684\u7c7b\u578b\u548cptr\u662f\u4e0d\u540c\u7684\u3002<br \/>\n\u8bf7\u95ee\u600e\u6837\u901a\u8fc7\u6307\u9488ptr\u6765\u8bbf\u95eess\u7684\u4e09\u4e2a\u6210\u5458\u53d8\u91cf\uff1f<br \/>\n\u7b54\u6848\uff1a<br \/>\nptr-&gt; a;<br \/>\nptr-&gt; b;<br \/>\nptr-&gt; c;<br \/>\n\u53c8\u8bf7\u95ee\u600e\u6837\u901a\u8fc7\u6307\u9488pstr\u6765\u8bbf\u95eess\u7684\u4e09\u4e2a\u6210\u5458\u53d8\u91cf\uff1f<br \/>\n\u7b54\u6848\uff1a<br \/>\n*pstr\uff1b\/\/\u8bbf\u95ee\u4e86ss\u7684\u6210\u5458a\u3002<br \/>\n*(pstr+1);\/\/\u8bbf\u95ee\u4e86ss\u7684\u6210\u5458b\u3002<br \/>\n*(pstr+2)\/\/\u8bbf\u95ee\u4e86ss\u7684\u6210\u5458c\u3002<br \/>\n\u867d\u7136\u6211\u5728\u6211\u7684MSVC++6.0\u4e0a\u8c03\u5f0f\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u4f46\u662f\u8981\u77e5\u9053\uff0c\u8fd9\u6837\u4f7f\u7528pstr\u6765\u8bbf\u95ee\u7ed3\u6784\u6210\u5458\u662f\u4e0d\u6b63\u89c4\u7684\uff0c\u4e3a\u4e86\u8bf4\u660e\u4e3a\u4ec0\u4e48\u4e0d\u6b63\u89c4\uff0c\u8ba9\u6211\u4eec\u770b\u770b\u600e\u6837\u901a\u8fc7\u6307\u9488\u6765\u8bbf\u95ee\u6570\u7ec4\u7684\u5404\u4e2a\u5355\u5143\uff1a<br \/>\n\u4f8b\u5341\u4e8c\uff1a<br \/>\nintarray[3]={35,56,37};<br \/>\nint*pa=array;<br \/>\n\u901a\u8fc7\u6307\u9488pa\u8bbf\u95ee\u6570\u7ec4array\u7684\u4e09\u4e2a\u5355\u5143\u7684\u65b9\u6cd5\u662f\uff1a<br \/>\n*pa;\/\/\u8bbf\u95ee\u4e86\u7b2c0\u53f7\u5355\u5143<br \/>\n*(pa+1);\/\/\u8bbf\u95ee\u4e86\u7b2c1\u53f7\u5355\u5143<br \/>\n*(pa+2);\/\/\u8bbf\u95ee\u4e86\u7b2c2\u53f7\u5355\u5143<\/p>\n<p>\u4ece\u683c\u5f0f\u4e0a\u770b\u5012\u662f\u4e0e\u901a\u8fc7\u6307\u9488\u8bbf\u95ee\u7ed3\u6784\u6210\u5458\u7684\u4e0d\u6b63\u89c4\u65b9\u6cd5\u7684\u683c\u5f0f\u4e00\u6837\u3002<br \/>\n\u6240\u6709\u7684C\/C++\u7f16\u8bd1\u5668\u5728\u6392\u5217\u6570\u7ec4\u7684\u5355\u5143\u65f6\uff0c\u603b\u662f\u628a\u5404\u4e2a\u6570\u7ec4\u5355\u5143\u5b58\u653e\u5728\u8fde\u7eed\u7684\u5b58\u50a8\u533a\u91cc\uff0c\u5355\u5143\u548c\u5355\u5143\u4e4b\u95f4\u6ca1\u6709\u7a7a\u9699\u3002\u4f46\u5728\u5b58\u653e\u7ed3\u6784\u5bf9\u8c61\u7684\u5404\u4e2a\u6210\u5458\u65f6\uff0c\u5728\u67d0 \u79cd\u7f16\u8bd1\u73af\u5883\u4e0b\uff0c\u53ef\u80fd\u4f1a\u9700\u8981\u5b57\u5bf9\u9f50\u6216\u53cc\u5b57\u5bf9\u9f50\u6216\u8005\u662f\u522b\u7684\u4ec0\u4e48\u5bf9\u9f50\uff0c\u9700\u8981\u5728\u76f8\u90bb\u4e24\u4e2a\u6210\u5458\u4e4b\u95f4\u52a0\u82e5\u5e72\u4e2a &#8220;\u586b\u5145\u5b57\u8282 &#8220;\uff0c\u8fd9\u5c31\u5bfc\u81f4\u5404\u4e2a\u6210\u5458\u4e4b\u95f4\u53ef\u80fd\u4f1a\u6709\u82e5\u5e72\u4e2a\u5b57\u8282\u7684\u7a7a\u9699\u3002<br \/>\n\u6240\u4ee5\uff0c\u5728\u4f8b\u5341\u4e8c\u4e2d\uff0c\u5373\u4f7f*pstr\u8bbf\u95ee\u5230\u4e86\u7ed3\u6784\u5bf9\u8c61ss\u7684\u7b2c\u4e00\u4e2a\u6210\u5458\u53d8\u91cfa\uff0c\u4e5f\u4e0d\u80fd\u4fdd\u8bc1*(pstr+1)\u5c31\u4e00\u5b9a\u80fd\u8bbf\u95ee\u5230\u7ed3\u6784\u6210\u5458b\u3002\u56e0\u4e3a\u6210\u5458a\u548c\u6210 \u5458b\u4e4b\u95f4\u53ef\u80fd\u4f1a\u6709\u82e5\u5e72\u586b\u5145\u5b57\u8282\uff0c\u8bf4\u4e0d\u5b9a*(pstr+1)\u5c31\u6b63\u597d\u8bbf\u95ee\u5230\u4e86\u8fd9\u4e9b\u586b\u5145\u5b57\u8282\u5462\u3002\u8fd9\u4e5f\u8bc1\u660e\u4e86\u6307\u9488\u7684\u7075\u6d3b\u6027\u3002\u8981\u662f\u4f60\u7684\u76ee\u7684\u5c31\u662f\u60f3\u770b\u770b\u5404\u4e2a\u7ed3\u6784\u6210\u5458\u4e4b \u95f4\u5230\u5e95\u6709\u6ca1\u6709\u586b\u5145\u5b57\u8282\uff0c\u563f\uff0c\u8fd9\u5012\u662f\u4e2a\u4e0d\u9519\u7684\u65b9\u6cd5\u3002<br \/>\n\u8fc7\u6307\u9488\u8bbf\u95ee\u7ed3\u6784\u6210\u5458\u7684\u6b63\u786e\u65b9\u6cd5\u5e94\u8be5\u662f\u8c61\u4f8b\u5341\u4e8c\u4e2d\u4f7f\u7528\u6307\u9488ptr\u7684\u65b9\u6cd5\u3002<br \/>\n\u6307\u9488\u548c\u51fd\u6570\u7684\u5173\u7cfb<br \/>\n\u53ef\u4ee5\u628a\u4e00\u4e2a\u6307\u9488\u58f0\u660e\u6210\u4e3a\u4e00\u4e2a\u6307\u5411\u51fd\u6570\u7684\u6307\u9488\u3002intfun1(char*,int);<br \/>\nint(*pfun1)(char*,int);<br \/>\npfun1=fun1;<br \/>\n&#8230;.<br \/>\n&#8230;.<br \/>\ninta=(*pfun1)( &#8220;abcdefg &#8220;,7);\/\/\u901a\u8fc7\u51fd\u6570\u6307\u9488\u8c03\u7528\u51fd\u6570\u3002<br \/>\n\u53ef\u4ee5\u628a\u6307\u9488\u4f5c\u4e3a\u51fd\u6570\u7684\u5f62\u53c2\u3002\u5728\u51fd\u6570\u8c03\u7528\u8bed\u53e5\u4e2d\uff0c\u53ef\u4ee5\u7528\u6307\u9488\u8868\u8fbe\u5f0f\u6765\u4f5c\u4e3a\u5b9e\u53c2\u3002<br \/>\n\u4f8b\u5341\u4e09\uff1a<br \/>\nintfun(char*);<br \/>\ninta;<br \/>\ncharstr[]= &#8220;abcdefghijklmn &#8220;;<br \/>\na=fun(str);<br \/>\n&#8230;<br \/>\n&#8230;<br \/>\nintfun(char*s)<br \/>\n{<br \/>\nintnum=0;<br \/>\nfor(inti=0;i{<br \/>\nnum+=*s;s++;<br \/>\n}<br \/>\nreturnnum;<br \/>\n}<br \/>\n\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\u7684\u51fd\u6570fun\u7edf\u8ba1\u4e00\u4e2a\u5b57\u7b26\u4e32\u4e2d\u5404\u4e2a\u5b57\u7b26\u7684ASCII\u7801\u503c\u4e4b\u548c\u3002\u524d\u9762\u8bf4\u4e86\uff0c\u6570\u7ec4\u7684\u540d\u5b57\u4e5f\u662f\u4e00\u4e2a\u6307\u9488\u3002\u5728\u51fd\u6570\u8c03\u7528\u4e2d\uff0c\u5f53\u628astr\u4f5c\u4e3a\u5b9e\u53c2\u4f20\u9012\u7ed9 \u5f62\u53c2s\u540e\uff0c\u5b9e\u9645\u662f\u628astr\u7684\u503c\u4f20\u9012\u7ed9\u4e86s\uff0cs\u6240\u6307\u5411\u7684\u5730\u5740\u5c31\u548cstr\u6240\u6307\u5411\u7684\u5730\u5740\u4e00\u81f4\uff0c\u4f46\u662fstr\u548cs\u5404\u81ea\u5360\u7528\u5404\u81ea\u7684\u5b58\u50a8\u7a7a\u95f4\u3002\u5728\u51fd\u6570\u4f53\u5185\u5bf9s\u8fdb\u884c\u81ea\u52a01 \u8fd0\u7b97\uff0c\u5e76\u4e0d\u610f\u5473\u7740\u540c\u65f6\u5bf9str\u8fdb\u884c\u4e86\u81ea\u52a01\u8fd0\u7b97\u3002<br \/>\n\u6307\u9488\u7c7b\u578b\u8f6c\u6362<br \/>\n\u5f53\u6211\u4eec\u521d\u59cb\u5316\u4e00\u4e2a\u6307\u9488\u6216\u7ed9\u4e00\u4e2a\u6307\u9488\u8d4b\u503c\u65f6\uff0c\u8d4b\u503c\u53f7\u7684\u5de6\u8fb9\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u8d4b\u503c\u53f7\u7684\u53f3\u8fb9\u662f\u4e00\u4e2a\u6307\u9488\u8868\u8fbe\u5f0f\u3002\u5728\u6211\u4eec\u524d\u9762\u6240\u4e3e\u7684\u4f8b\u5b50\u4e2d\uff0c\u7edd\u5927\u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u6307\u9488\u7684\u7c7b\u578b\u548c\u6307\u9488\u8868\u8fbe\u5f0f\u7684\u7c7b\u578b\u662f\u4e00\u6837\u7684\uff0c\u6307\u9488\u6240\u6307\u5411\u7684\u7c7b\u578b\u548c\u6307\u9488\u8868\u8fbe\u5f0f\u6240\u6307\u5411\u7684\u7c7b\u578b\u662f\u4e00\u6837\u7684\u3002<br \/>\n\u4f8b\u5341\u56db\uff1a<br \/>\n1\u3001floatf=12.3;<br \/>\n2\u3001float*fptr=&amp;f;<br \/>\n3\u3001int*p;<br \/>\n\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u5047\u5982\u6211\u4eec\u60f3\u8ba9\u6307\u9488p\u6307\u5411\u5b9e\u6570f\uff0c\u5e94\u8be5\u600e\u4e48\u641e\uff1f\u662f\u7528\u4e0b\u9762\u7684\u8bed\u53e5\u5417\uff1f<\/p>\n<p>p=&amp;f;<\/p>\n<p>\u4e0d\u5bf9\u3002\u56e0\u4e3a\u6307\u9488p\u7684\u7c7b\u578b\u662fint*\uff0c\u5b83\u6307\u5411\u7684\u7c7b\u578b\u662fint\u3002\u8868\u8fbe\u5f0f&amp;f\u7684\u7ed3\u679c\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u6307\u9488\u7684\u7c7b\u578b\u662ffloat*,\u5b83\u6307\u5411\u7684\u7c7b\u578b\u662f float\u3002\u4e24\u8005\u4e0d\u4e00\u81f4\uff0c\u76f4\u63a5\u8d4b\u503c\u7684\u65b9\u6cd5\u662f\u4e0d\u884c\u7684\u3002\u81f3\u5c11\u5728\u6211\u7684MSVC++6.0\u4e0a\uff0c\u5bf9\u6307\u9488\u7684\u8d4b\u503c\u8bed\u53e5\u8981\u6c42\u8d4b\u503c\u53f7\u4e24\u8fb9\u7684\u7c7b\u578b\u4e00\u81f4\uff0c\u6240\u6307\u5411\u7684\u7c7b\u578b\u4e5f\u4e00\u81f4\uff0c\u5176 \u5b83\u7684\u7f16\u8bd1\u5668\u4e0a\u6211\u6ca1\u8bd5\u8fc7\uff0c\u5927\u5bb6\u53ef\u4ee5\u8bd5\u8bd5\u3002\u4e3a\u4e86\u5b9e\u73b0\u6211\u4eec\u7684\u76ee\u7684\uff0c\u9700\u8981\u8fdb\u884c &#8220;\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362 &#8220;\uff1a<br \/>\np=(int*)&amp;f;<br \/>\n\u5982\u679c\u6709\u4e00\u4e2a\u6307\u9488p\uff0c\u6211\u4eec\u9700\u8981\u628a\u5b83\u7684\u7c7b\u578b\u548c\u6240\u6307\u5411\u7684\u7c7b\u578b\u6539\u4e3aTYEP*TYPE\uff0c \u90a3\u4e48\u8bed\u6cd5\u683c\u5f0f\u662f\uff1a<br \/>\n(TYPE*)p\uff1b<br \/>\n\u8fd9\u6837\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\u7684\u7ed3\u679c\u662f\u4e00\u4e2a\u65b0\u6307\u9488\uff0c\u8be5\u65b0\u6307\u9488\u7684\u7c7b\u578b\u662fTYPE*\uff0c\u5b83\u6307\u5411\u7684\u7c7b\u578b\u662fTYPE\uff0c\u5b83\u6307\u5411\u7684\u5730\u5740\u5c31\u662f\u539f\u6307\u9488\u6307\u5411\u7684\u5730\u5740\u3002\u800c\u539f\u6765\u7684\u6307\u9488p\u7684\u4e00\u5207\u5c5e\u6027\u90fd\u6ca1\u6709\u88ab\u4fee\u6539\u3002<br \/>\n\u4e00\u4e2a\u51fd\u6570\u5982\u679c\u4f7f\u7528\u4e86\u6307\u9488\u4f5c\u4e3a\u5f62\u53c2\uff0c\u90a3\u4e48\u5728\u51fd\u6570\u8c03\u7528\u8bed\u53e5\u7684\u5b9e\u53c2\u548c\u5f62\u53c2\u7684\u7ed3\u5408\u8fc7\u7a0b\u4e2d\uff0c\u4e5f\u4f1a\u53d1\u751f\u6307\u9488\u7c7b\u578b\u7684\u8f6c\u6362\u3002<br \/>\n\u4f8b\u5341\u4e94\uff1a<br \/>\nvoidfun(char*);<br \/>\ninta=125,b;<br \/>\nfun((char*)&amp;a);<br \/>\n&#8230;<br \/>\n&#8230;<br \/>\nvoidfun(char*s)<br \/>\n{<br \/>\ncharc;<br \/>\nc=*(s+3);*(s+3)=*(s+0);*(s+0)=c;<br \/>\nc=*(s+2);*(s+2)=*(s+1);*(s+1)=c;<br \/>\n}<br \/>\n}<br \/>\n\u6ce8\u610f\u8fd9\u662f\u4e00\u4e2a32\u4f4d\u7a0b\u5e8f\uff0c\u6545int\u7c7b\u578b\u5360\u4e86\u56db\u4e2a\u5b57\u8282\uff0cchar\u7c7b\u578b\u5360\u4e00\u4e2a\u5b57\u8282\u3002\u51fd\u6570fun\u7684\u4f5c\u7528\u662f\u628a\u4e00\u4e2a\u6574\u6570\u7684\u56db\u4e2a\u5b57\u8282\u7684\u987a\u5e8f\u6765\u4e2a\u98a0\u5012\u3002\u6ce8\u610f\u5230\u4e86\u5417\uff1f\u5728\u51fd \u6570\u8c03\u7528\u8bed\u53e5\u4e2d\uff0c\u5b9e\u53c2&amp;a\u7684\u7ed3\u679c\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u5b83\u7684\u7c7b\u578b\u662fint*\uff0c\u5b83\u6307\u5411\u7684\u7c7b\u578b\u662fint\u3002\u5f62\u53c2\u8fd9\u4e2a\u6307\u9488\u7684\u7c7b\u578b\u662fchar*\uff0c\u5b83\u6307\u5411\u7684\u7c7b\u578b\u662f char\u3002\u8fd9\u6837\uff0c\u5728\u5b9e\u53c2\u548c\u5f62\u53c2\u7684\u7ed3\u5408\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u5fc5\u987b\u8fdb\u884c\u4e00\u6b21\u4eceint*\u7c7b\u578b\u5230char*\u7c7b\u578b\u7684\u8f6c\u6362\u3002\u7ed3\u5408\u8fd9\u4e2a\u4f8b\u5b50\uff0c\u6211\u4eec\u53ef\u4ee5\u8fd9\u6837\u6765\u60f3\u8c61\u7f16\u8bd1\u5668\u8fdb\u884c\u8f6c\u6362\u7684 \u8fc7\u7a0b\uff1a\u7f16\u8bd1\u5668\u5148\u6784\u9020\u4e00\u4e2a\u4e34\u65f6\u6307\u9488char*temp\uff0c \u7136\u540e\u6267\u884ctemp=(char*)&amp;a\uff0c\u6700\u540e\u518d\u628atemp\u7684\u503c\u4f20\u9012\u7ed9s\u3002\u6240\u4ee5\u6700\u540e\u7684\u7ed3\u679c\u662f\uff1as\u7684\u7c7b\u578b\u662fchar*,\u5b83\u6307\u5411\u7684\u7c7b\u578b\u662fchar\uff0c\u5b83\u6307 \u5411\u7684\u5730\u5740\u5c31\u662fa\u7684\u9996\u5730\u5740\u3002<\/p>\n<p>\u6211\u4eec\u5df2\u7ecf\u77e5\u9053\uff0c\u6307\u9488\u7684\u503c\u5c31\u662f\u6307\u9488\u6307\u5411\u7684\u5730\u5740\uff0c\u572832\u4f4d\u7a0b\u5e8f\u4e2d\uff0c\u6307\u9488\u7684\u503c\u5176\u5b9e\u662f\u4e00\u4e2a32\u4f4d\u6574\u6570\u3002\u90a3\u53ef\u4e0d\u53ef\u4ee5\u628a\u4e00\u4e2a\u6574\u6570\u5f53\u4f5c\u6307\u9488\u7684\u503c\u76f4\u63a5\u8d4b\u7ed9\u6307\u9488\u5462\uff1f\u5c31\u8c61\u4e0b\u9762\u7684\u8bed\u53e5\uff1a<br \/>\nunsignedinta;<br \/>\nTYPE*ptr;\/\/TYPE\u662fint\uff0cchar\u6216\u7ed3\u6784\u7c7b\u578b\u7b49\u7b49\u7c7b\u578b\u3002<br \/>\n&#8230;<br \/>\n&#8230;<br \/>\na=20345686;<br \/>\nptr=20345686;\/\/\u6211\u4eec\u7684\u76ee\u7684\u662f\u8981\u4f7f\u6307\u9488ptr\u6307\u5411\u5730\u574020345686\uff08\u5341\u8fdb\u5236<br \/>\n\uff09<br \/>\nptr=a;\/\/\u6211\u4eec\u7684\u76ee\u7684\u662f\u8981\u4f7f\u6307\u9488ptr\u6307\u5411\u5730\u574020345686\uff08\u5341\u8fdb\u5236\uff09<br \/>\n\u7f16\u8bd1\u4e00\u4e0b\u5427\u3002\u7ed3\u679c\u53d1\u73b0\u540e\u9762\u4e24\u6761\u8bed\u53e5\u5168\u662f\u9519\u7684\u3002\u90a3\u4e48\u6211\u4eec\u7684\u76ee\u7684\u5c31\u4e0d\u80fd\u8fbe\u5230\u4e86\u5417\uff1f\u4e0d\uff0c\u8fd8\u6709\u529e\u6cd5\uff1a<br \/>\nunsignedinta;<br \/>\nTYPE*ptr;\/\/TYPE\u662fint\uff0cchar\u6216\u7ed3\u6784\u7c7b\u578b\u7b49\u7b49\u7c7b\u578b\u3002<br \/>\n&#8230;<br \/>\n&#8230;<br \/>\na=\u67d0\u4e2a\u6570\uff0c\u8fd9\u4e2a\u6570\u5fc5\u987b\u4ee3\u8868\u4e00\u4e2a\u5408\u6cd5\u7684\u5730\u5740\uff1b<br \/>\nptr=(TYPE*)a\uff1b\/\/\u5475\u5475\uff0c\u8fd9\u5c31\u53ef\u4ee5\u4e86\u3002<br \/>\n\u4e25\u683c\u8bf4\u6765\u8fd9\u91cc\u7684(TYPE*)\u548c\u6307\u9488\u7c7b\u578b\u8f6c\u6362\u4e2d\u7684(TYPE*)\u8fd8\u4e0d\u4e00\u6837\u3002\u8fd9\u91cc\u7684(TYPE*)\u7684\u610f\u601d\u662f\u628a\u65e0\u7b26\u53f7\u6574\u6570a\u7684\u503c\u5f53\u4f5c\u4e00\u4e2a\u5730\u5740\u6765\u770b\u5f85\u3002\u4e0a\u9762\u5f3a\u8c03\u4e86a\u7684\u503c\u5fc5\u987b\u4ee3\u8868\u4e00\u4e2a\u5408\u6cd5\u7684\u5730\u5740\uff0c\u5426\u5219\u7684\u8bdd\uff0c\u5728\u4f60\u4f7f\u7528ptr\u7684\u65f6\u5019\uff0c\u5c31\u4f1a\u51fa\u73b0\u975e\u6cd5\u64cd\u4f5c\u9519\u8bef\u3002<\/p>\n<p>\u60f3\u60f3\u80fd\u4e0d\u80fd\u53cd\u8fc7\u6765\uff0c\u628a\u6307\u9488\u6307\u5411\u7684\u5730\u5740\u5373\u6307\u9488\u7684\u503c\u5f53\u4f5c\u4e00\u4e2a\u6574\u6570\u53d6\u51fa\u6765\u3002\u5b8c \u5168\u53ef\u4ee5\u3002\u4e0b\u9762\u7684\u4f8b\u5b50\u6f14\u793a\u4e86\u628a\u4e00\u4e2a\u6307\u9488\u7684\u503c\u5f53\u4f5c\u4e00\u4e2a\u6574\u6570\u53d6\u51fa\u6765\uff0c\u7136\u540e\u518d\u628a\u8fd9\u4e2a\u6574\u6570\u5f53\u4f5c\u4e00\u4e2a\u5730\u5740\u8d4b\u7ed9\u4e00\u4e2a\u6307\u9488\uff1a<br \/>\n\u4f8b\u5341\u516d\uff1a<br \/>\ninta=123,b;<br \/>\nint*ptr=&amp;a;<br \/>\nchar*str;<br \/>\nb=(int)ptr;\/\/\u628a\u6307\u9488ptr\u7684\u503c\u5f53\u4f5c\u4e00\u4e2a\u6574\u6570\u53d6\u51fa\u6765\u3002<br \/>\nstr=(char*)b;\/\/\u628a\u8fd9\u4e2a\u6574\u6570\u7684\u503c\u5f53\u4f5c\u4e00\u4e2a\u5730\u5740\u8d4b\u7ed9\u6307\u9488str\u3002<br \/>\n\u73b0\u5728\u6211\u4eec\u5df2\u7ecf\u77e5\u9053\u4e86\uff0c\u53ef\u4ee5\u628a\u6307\u9488\u7684\u503c\u5f53\u4f5c\u4e00\u4e2a\u6574\u6570\u53d6\u51fa\u6765\uff0c\u4e5f\u53ef\u4ee5\u628a\u4e00\u4e2a\u6574\u6570\u503c\u5f53\u4f5c\u5730\u5740\u8d4b\u7ed9\u4e00\u4e2a\u6307\u9488\u3002<br \/>\n\u6307\u9488\u7684\u5b89\u5168\u95ee\u9898<br \/>\n\u770b\u4e0b\u9762\u7684\u4f8b\u5b50\uff1a<br \/>\n\u4f8b\u5341\u4e03\uff1a<br \/>\nchars= &#8216;a &#8216;;<br \/>\nint*ptr;<br \/>\nptr=(int*)&amp;s;<br \/>\n*ptr=1298\uff1b<br \/>\n\u6307\u9488ptr\u662f\u4e00\u4e2aint*\u7c7b\u578b\u7684\u6307\u9488\uff0c\u5b83\u6307\u5411\u7684\u7c7b\u578b\u662fint\u3002\u5b83\u6307\u5411\u7684\u5730\u5740\u5c31\u662fs\u7684\u9996\u5730\u5740\u3002\u572832\u4f4d\u7a0b\u5e8f\u4e2d\uff0cs\u5360\u4e00\u4e2a\u5b57\u8282\uff0cint\u7c7b\u578b\u5360\u56db\u4e2a\u5b57\u8282\u3002\u6700 \u540e\u4e00\u6761\u8bed\u53e5\u4e0d\u4f46\u6539\u53d8\u4e86s\u6240\u5360\u7684\u4e00\u4e2a\u5b57\u8282\uff0c\u8fd8\u628a\u548cs\u76f8\u4e34\u7684\u9ad8\u5730\u5740\u65b9\u5411\u7684\u4e09\u4e2a\u5b57\u8282\u4e5f\u6539\u53d8\u4e86\u3002\u8fd9\u4e09\u4e2a\u5b57\u8282\u662f\u5e72\u4ec0\u4e48\u7684\uff1f\u53ea\u6709\u7f16\u8bd1\u7a0b\u5e8f\u77e5\u9053\uff0c\u800c\u5199\u7a0b\u5e8f\u7684\u4eba\u662f\u4e0d\u592a\u53ef\u80fd \u77e5\u9053\u7684\u3002\u4e5f\u8bb8\u8fd9\u4e09\u4e2a\u5b57\u8282\u91cc\u5b58\u50a8\u4e86\u975e\u5e38\u91cd\u8981\u7684\u6570\u636e\uff0c\u4e5f\u8bb8\u8fd9\u4e09\u4e2a\u5b57\u8282\u91cc\u6b63\u597d\u662f\u7a0b\u5e8f\u7684\u4e00\u6761\u4ee3\u7801\uff0c\u800c\u7531\u4e8e\u4f60\u5bf9\u6307\u9488\u7684\u9a6c\u864e\u5e94\u7528\uff0c\u8fd9\u4e09\u4e2a\u5b57\u8282\u7684\u503c\u88ab\u6539\u53d8\u4e86\uff01\u8fd9\u4f1a\u9020\u6210\u5d29 \u6e83\u6027\u7684\u9519\u8bef\u3002<br \/>\n\u8ba9\u6211\u4eec\u518d\u6765\u770b\u4e00\u4f8b\uff1a<br \/>\n\u4f8b\u5341\u516b\uff1a<br \/>\n1\u3001chara;<br \/>\n2\u3001int*ptr=&amp;a;<br \/>\n&#8230;<br \/>\n&#8230;<br \/>\n3\u3001ptr++;<br \/>\n4\u3001*ptr=115;<br \/>\n\u8be5\u4f8b\u5b50\u5b8c\u5168\u53ef\u4ee5\u901a\u8fc7\u7f16\u8bd1\uff0c\u5e76\u80fd\u6267\u884c\u3002\u4f46\u662f\u770b\u5230\u6ca1\u6709\uff1f\u7b2c3\u53e5\u5bf9\u6307\u9488ptr\u8fdb\u884c\u81ea\u52a01\u8fd0\u7b97\u540e\uff0cptr\u6307\u5411\u4e86\u548c\u6574\u5f62\u53d8\u91cfa\u76f8\u90bb\u7684\u9ad8\u5730\u5740\u65b9\u5411\u7684\u4e00\u5757\u5b58\u50a8\u533a\u3002\u8fd9 \u5757\u5b58\u50a8\u533a\u91cc\u662f\u4ec0\u4e48\uff1f\u6211\u4eec\u4e0d\u77e5\u9053\u3002\u6709\u53ef\u80fd\u5b83\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6570\u636e\uff0c\u751a\u81f3\u53ef\u80fd\u662f\u4e00\u6761\u4ee3\u7801\u3002\u800c\u7b2c4\u53e5\u7adf\u7136\u5f80\u8fd9\u7247\u5b58\u50a8\u533a\u91cc\u5199\u5165\u4e00\u4e2a\u6570\u636e\uff01\u8fd9\u662f\u4e25\u91cd\u7684\u9519\u8bef\u3002\u6240\u4ee5\u5728\u4f7f \u7528\u6307\u9488\u65f6\uff0c\u7a0b\u5e8f\u5458\u5fc3\u91cc\u5fc5\u987b\u975e\u5e38\u6e05\u695a\uff1a\u6211\u7684\u6307\u9488\u7a76\u7adf\u6307\u5411\u4e86\u54ea\u91cc\u3002\u5728\u7528\u6307\u9488\u8bbf\u95ee\u6570\u7ec4\u7684\u65f6\u5019\uff0c\u4e5f\u8981\u6ce8\u610f\u4e0d\u8981\u8d85\u51fa\u6570\u7ec4\u7684\u4f4e\u7aef\u548c\u9ad8\u7aef\u754c\u9650\uff0c\u5426\u5219\u4e5f\u4f1a\u9020\u6210\u7c7b\u4f3c\u7684\u9519\u8bef\u3002<br \/>\n\u5728\u6307\u9488\u7684\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\uff1aptr1=(TYPE*)ptr2\u4e2d\uff0c\u5982\u679csizeof(ptr2\u7684\u7c7b\u578b)\u5927\u4e8esizeof(ptr1\u7684\u7c7b\u578b)\uff0c\u90a3\u4e48\u5728\u4f7f\u7528\u6307 \u9488ptr1\u6765\u8bbf\u95eeptr2\u6240\u6307\u5411\u7684\u5b58\u50a8\u533a\u65f6\u662f\u5b89\u5168\u7684\u3002\u5982\u679csizeof(ptr2\u7684\u7c7b\u578b)\u5c0f\u4e8esizeof(ptr1\u7684\u7c7b\u578b)\uff0c\u90a3\u4e48\u5728\u4f7f\u7528\u6307\u9488ptr1\u6765 \u8bbf\u95eeptr2\u6240\u6307\u5411\u7684\u5b58\u50a8\u533a\u65f6\u662f\u4e0d\u5b89\u5168\u7684\u3002\u81f3\u4e8e\u4e3a\u4ec0\u4e48\uff0c\u8bfb\u8005\u7ed3\u5408\u4f8b\u5341\u4e03\u6765\u60f3\u4e00\u60f3\uff0c\u5e94\u8be5\u4f1a\u660e\u767d\u7684\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6307\u9488\u662f\u4e00\u4e2a\u7279\u6b8a\u7684\u53d8\u91cf\uff0c\u5b83\u91cc\u9762\u5b58\u50a8\u7684\u6570\u503c\u88ab\u89e3\u91ca\u6210\u4e3a\u5185\u5b58\u91cc\u7684\u4e00\u4e2a\u5730\u5740\u3002 \u8981\u641e\u6e05\u4e00\u4e2a\u6307\u9488\u9700\u8981\u641e\u6e05\u6307\u9488\u7684\u56db\u65b9\u9762\u7684\u5185\u5bb9\uff1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-648","post","type-post","status-publish","format-standard","hentry","category-code_related"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=648"}],"version-history":[{"count":1,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/648\/revisions"}],"predecessor-version":[{"id":5181,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/648\/revisions\/5181"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}