<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>https://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>https://jackxiang.com/post//</link>
<title><![CDATA[C语言中实现数组的动态增长]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Tue, 09 Dec 2008 08:14:02 +0000</pubDate> 
<guid>https://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	在c语言中实现数组的动态增长<br/>原理：在c语言中数组下标访问可以看成指针偏移访问<br/>1、对表进行检查，看看它是否真的已满<br/>2、如果表确实已满，使用realloc()函数扩展表的长度，<br/> 并进行检查，确保realloc()操作成功进行。<br/>3、在表中增加所需要的项目。<br/>代码如下：<br/><br/><div class="code">int current_element=0;<br/>int total_element=128;<br/>char *dynamic=malloc(total_element);<br/>char *ptr;<br/><br/>void add_element(char c)<br/>&#123;<br/> if(current_element==total_element-1)<br/> &#123;<br/>&nbsp;&nbsp;total_element *=2;<br/>&nbsp;&nbsp;ptr=(char*)realloc(dynamic,total_element);<br/>&nbsp;&nbsp;if(ptr==NULL)<br/>&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp; printf(&quot;can&#039;t expand the table!&#92;n&quot;); <br/>&nbsp;&nbsp; return -1;<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;else<br/>&nbsp;&nbsp; dynamic=ptr;&nbsp;&nbsp; <br/> &#125;<br/> current_element++;<br/> dynamic&#91;current_element&#93;=c;<br/>&#125;</div>注：在实践中，不要把realloc()函数的返回值直接赋给字符指针，<br/>如果realloc()函数失败，它会使该指针的值变成NULL，这样就无法<br/>对现有的表进行访问。
]]>
</description>
</item><item>
<link>https://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] C语言中实现数组的动态增长]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>