<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://jackxiang.com/post//</link>
<title><![CDATA[[实践OK]数组的首地址是一个指针，和单个不一样，数组可以取越界。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Unix/LinuxC技术]]></category>
<pubDate>Fri, 18 Oct 2019 06:53:30 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	背景：好久没有摸C了，顺带学一下C语言数组下标的越界是否能访问到东西的问题，是能访问到的，但这些值没有任何意义，可能对于一些黑客有一定意义，但咱不细深入，简单了解一下即可。<br/><br/>cat test.c <br/><textarea name="code" class="php" rows="15" cols="100">
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

int main()
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;int *j;
&nbsp;&nbsp;&nbsp;&nbsp;int i[3] = &#123;99, 100, 101&#125;;
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;i[0]===%d&#92;n&quot;, i[0]);
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;i[1]===%d&#92;n&quot;, i[1]);
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;i[2]===%d&#92;n&quot;, i[2]);
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;i[3]===%d&#92;n&quot;, i[3]);
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;i[4]===%d&#92;n&quot;, i[4]);
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;i[5]===%d&#92;n&quot;, i[5]);
&nbsp;&nbsp;&nbsp;&nbsp;//i is a arr pointer
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;*i===%d&#92;n&quot;, *i);
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;*(i+1)===%d&#92;n&quot;, *(i+1));
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;*(i+2)===%d&#92;n&quot;, *(i+2));
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;*(i+3)===%d&#92;n&quot;, *(i+3));
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;*(i+4)===%d&#92;n&quot;, *(i+4));
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;*(i+5)===%d&#92;n&quot;, *(i+5));
&nbsp;&nbsp;&nbsp;&nbsp;j=i;
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;&#92;n*j===%d&#92;n&quot;, *j);
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;*(j+1)===%d&#92;n&quot;, *(j+1));
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;*(j+2)===%d&#92;n&quot;, *(j+2));
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;*(j+3)===%d&#92;n&quot;, *(j+3));
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;*(j+4)===%d&#92;n&quot;, *(j+4));
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;*(j+5)===%d&#92;n&quot;, *(j+5));
&nbsp;&nbsp;&nbsp;&nbsp;exit(0);
&#125;
</textarea><br/><br/><br/>#make test&nbsp;&nbsp;<br/>cc&nbsp;&nbsp;&nbsp;&nbsp; test.c&nbsp;&nbsp; -o test<br/><br/><br/>#./test<br/>i[0]===99<br/>i[1]===100<br/>i[2]===101<br/>i[3]===0<br/>i[4]===1559561856<br/>i[5]===32764<br/>*i===99<br/>*(i+1)===100<br/>*(i+2)===101<br/>*(i+3)===0<br/>*(i+4)===1559561856<br/>*(i+5)===32764<br/><br/>*j===99<br/>*(j+1)===100<br/>*(j+2)===101<br/>*(j+3)===0<br/>*(j+4)===1559561856<br/>*(j+5)===32764<br/><br/><br/>===<br/>如果不是整数数组，只是一个定义整数，j=i;是不行的，得：<br/>&nbsp;&nbsp;&nbsp;&nbsp;int a = 6;<br/>&nbsp;&nbsp;&nbsp;&nbsp;int *p = &amp;a;<br/><br/>原因是：数组的首地址是指针，而单个整数变量不是指针，上面这个情况得用&amp;取到其地址赋值给指针变量p，如下：<br/>int *p;<br/>p = &amp;a;
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] [实践OK]数组的首地址是一个指针，和单个不一样，数组可以取越界。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>