{"id":402,"date":"2023-02-25T10:48:14","date_gmt":"2023-02-25T02:48:14","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=402"},"modified":"2023-04-29T21:37:29","modified_gmt":"2023-04-29T13:37:29","slug":"android-ndk-basic-c-pointer-type-null-pointer-multi-level-pointer-pointer-operation","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/25\/android-ndk-basic-c-pointer-type-null-pointer-multi-level-pointer-pointer-operation\/","title":{"rendered":"Android NDK\u57fa\u78402\uff1aC_\u6307\u9488\u7c7b\u578b_\u7a7a\u6307\u9488_\u591a\u7ea7\u6307\u9488_\u6307\u9488\u8fd0\u7b97"},"content":{"rendered":"<h2>\u6307\u9488\u7c7b\u578b<\/h2>\n<pre><code class=\"language-c\">#include &lt;stdio.h&gt;\n#include &lt;stdlib.h&gt;\n\n\/\/1.\u6307\u9488\u4e3a\u4ec0\u4e48\u8981\u6709\u7c7b\u578b\uff1f\n\/\/\u6307\u9488\u6709\u7c7b\u578b\uff0c\u5730\u5740\u6ca1\u6709\u7c7b\u578b\n\/\/\u5730\u5740\u53ea\u662f\u5f00\u59cb\u7684\u4f4d\u7f6e\uff0c\u7c7b\u578b\u8bfb\u53d6\u5230\u4ec0\u4e48\u4f4d\u7f6e\u7ed3\u675f\nvoid main() {\n    int i = 100;\n    \/\/int \u7c7b\u578b\u7684\u6307\u9488\n    int *p = &amp;i;\n    double j = 78.9;\n    \/\/\u8d4b\u503c\u4e3adouble\u7c7b\u578b\u53d8\u91cf\u7684\u5730\u5740\n    p = &amp;j;\n    printf(&quot;double size:%d\\n&quot;, sizeof(double));\n    printf(&quot;%#x, %lf\\n&quot;, p, *p); \/\/\u60f3\u901a\u8fc74\u5b57\u8282\u8bfb\u53d68\u5b57\u8282\u53d8\u91cf\u7684\u503c\uff0c\u662f\u4e0d\u884c\u7684   \n\n    getchar();\n}<\/code><\/pre>\n<p><!-- more --><\/p>\n<h2>\u7a7a\u6307\u9488<\/h2>\n<pre><code class=\"language-c\">\/\/2.NULL\u7a7a\u6307\u9488\nvoid main() {\n    int i = 9;\n    int *p = NULL;\n   \/\/p = &amp;i;\n\n    \/\/\u7a7a\u6307\u9488\u7684\u9ed8\u8ba4\u503c\u4e3a0\n    printf(&quot;%#x\\n&quot;, p);\n    \/\/\u8bbf\u95ee\u5185\u5b58\u5730\u57400x000000\u64cd\u4f5c\u7cfb\u7edf\u4e0d\u5141\u8bb8\n    \/\/p = 100; \/\/\u64cd\u4f5c\u7cfb\u7edf\u4e0d\u5141\u8bb8\u8bbf\u95ee\n    printf(&quot;%d\\n&quot;, *p);\n    getchar();\n}<\/code><\/pre>\n<h2>\u591a\u7ea7\u6307\u9488<\/h2>\n<pre><code class=\"language-c\">\/\/3.\u591a\u7ea7\u6307\u9488\uff08\u4e8c\u7ea7\u6307\u9488\uff09\n\/\/\u6307\u9488\u4fdd\u5b58\u7684\u662f\u53d8\u91cf\u7684\u5730\u5740\uff0c\u4fdd\u5b58\u7684\u8fd9\u4e2a\u53d8\u91cf\u8fd8\u53ef\u4ee5\u662f\u4e00\u4e2a\u6307\u9488\u53d8\u91cf\n\/\/\u52a8\u6001\u5185\u5b58\u5206\u914d\u7ed9\u4e8c\u7ef4\u6570\u7ec4\nvoid main() {\n    int a = 50;\n    \/\/p1\u4e0a\u4fdd\u5b58\u7684a\u7684\u5730\u5740\n    int* p1 = &amp;a;\n\n    \/\/p2\u4e0a\u4fdd\u5b58\u7684p1\u7684\u5730\u5740\n    int** p2 = &amp;p1;\n\n    \/\/int*** p3 = &amp;p2;\n\n    printf(&quot;p1:%#x, p2:%#x\\n&quot;, p1, p2);\n\n    **p2 = 100;\n    printf(&quot;%d\\n&quot;,a);\n\n    getchar();\n}<\/code><\/pre>\n<h2>\u6307\u9488\u8fd0\u7b97<\/h2>\n<pre><code class=\"language-c\">\/\/4.\u6307\u9488\u7684\u8fd0\u7b97\n\/\/\u6307\u9488\u7684\u8fd0\u7b97\uff0c\u4e00\u822c\u5728\u6570\u7ec4\u904d\u5386\u65f6\u624d\u6709\u610f\u4e49\uff0c\u57fa\u4e8e\u6570\u7ec4\u5728\u5185\u5b58\u4e2d\u7ebf\u6027\u6392\u5217\u7684\u65b9\u5f0f\nvoid main() {\n    \/\/\u6570\u7ec4\u5728\u5185\u5b58\u4e2d\u8fde\u7eed\u5b58\u50a8\n    int ids[] = { 78, 90, 23, 65, 19 };\n    \/\/\u6570\u7ec4\u53d8\u91cf\u540d\uff1aids\u5c31\u662f\u6570\u7ec4\u7684\u9996\u5730\u5740\n    \/\/ids\u3001&amp;ids\u3001&amp;ids[0]\u90fd\u662f\u6570\u7ec4\u7684\u9996\u5730\u5740\n    printf(&quot;%#x\\n&quot;, ids);\n    printf(&quot;%#x\\n&quot;, &amp;ids);\n    printf(&quot;%#x\\n&quot;, &amp;ids[0]);\n    \/\/\u6307\u9488\u53d8\u91cf\n    int *p = ids;\n    printf(&quot;%d\\n&quot;, *p);\n    \/\/\u6307\u9488\u7684\u52a0\u6cd5\n    p++; \/\/p++\u5411\u524d\u79fb\u52a8sizeof(\u6570\u636e\u7c7b\u578b)\u4e2a\u5b57\u8282\n    printf(&quot;p\u7684\u503c:%#x\\n&quot;, p); \/\/p\u7684\u503c\u52a0\u4e864\n    \/\/p--;\n    printf(&quot;%d\\n&quot;, *p);\n   getchar();\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6307\u9488\u7c7b\u578b #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-402","post","type-post","status-publish","format-standard","hentry","category-android-ndk"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/402","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=402"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/402\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=402"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=402"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}