﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-华梦行-随笔分类-C</title><link>http://www.blogjava.net/huamengxing/category/38201.html</link><description>专注于java</description><language>zh-cn</language><lastBuildDate>Fri, 14 May 2010 11:23:02 GMT</lastBuildDate><pubDate>Fri, 14 May 2010 11:23:02 GMT</pubDate><ttl>60</ttl><item><title>写给c/c++</title><link>http://www.blogjava.net/huamengxing/archive/2010/05/08/320369.html</link><dc:creator>华梦行</dc:creator><author>华梦行</author><pubDate>Sat, 08 May 2010 11:30:00 GMT</pubDate><guid>http://www.blogjava.net/huamengxing/archive/2010/05/08/320369.html</guid><wfw:comment>http://www.blogjava.net/huamengxing/comments/320369.html</wfw:comment><comments>http://www.blogjava.net/huamengxing/archive/2010/05/08/320369.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huamengxing/comments/commentRss/320369.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huamengxing/services/trackbacks/320369.html</trackback:ping><description><![CDATA[<strong>
<h5>写给c/c++的新同行门，CTO门把你们的宝贵经验拿出来吧，让这个帖对大伙有用</h5>
<p>1、越界 <br />
<br />
　越界是最难查的，注意memcpy strcpy,strncpy这些函数使用前一定要检查边界 <br />
<br />
　特别是你提供函数给别人用时，你的函数中用到了这些东西，一定要检查别人传给你的指针的 <br />
　边界 <br />
<br />
2、变量初始化 <br />
<br />
　这种问题要养成好习惯，否则出来偶然性问题，非常难查 <br />
<br />
3、多线程指针管理 <br />
<br />
　在多线程环境下使用指针时，最好采用引用计数，让最后一个放充引用计数时，指针删除，避免一个线程在使用指针，另外线程删除掉 <br />
<br />
4、多线程锁的管理 <br />
<br />
　多线程锁要粒度要适中，尽量减少　一个函数　进入多个锁，避免一个大函数一个大锁影响性能，可学习数据库的表级，行级锁 <br />
<br />
　尽量不要在回调函数中放锁，易　引起死锁 <br />
<br />
做到线程安全函数单向调用，上层往下层调用，下屋向上层采用事件驱动反馈，避免调用栈 <br />
<br />
　过深，易引起死锁　 <br />
， <br />
5、多线程对象生存期管理 <br />
<br />
　尽量当多线程共享对象　尽量不要直接删除，建议采用状态机形式来管理，其它线程设置状态 <br />
<br />
　由一个线程统一按状态管理生存期 <br />
<br />
6、构造函数 <br />
<br />
函造函数中不要放虚函数，绝对不要在构造函数中开线程，并且线程调用自己的成员 <br />
<br />
7、内联 <br />
　 <br />
　　虚函数不要内联 <br />
<br />
8、多线程创建办法 <br />
<br />
如果用C运行库函数，要注意用C运行库的方法 <br />
<br />
9，内存管理 <br />
<br />
建议采用内存池管理 <br />
<br />
10、线程生存期管理 <br />
<br />
线程中尽量不要调用同步函数，不要强行杀线程，要让线程不断循环，等待死亡信号自己退出</p>
</strong>
<img src ="http://www.blogjava.net/huamengxing/aggbug/320369.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huamengxing/" target="_blank">华梦行</a> 2010-05-08 19:30 <a href="http://www.blogjava.net/huamengxing/archive/2010/05/08/320369.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>指针的理解</title><link>http://www.blogjava.net/huamengxing/archive/2010/03/08/314791.html</link><dc:creator>华梦行</dc:creator><author>华梦行</author><pubDate>Mon, 08 Mar 2010 03:07:00 GMT</pubDate><guid>http://www.blogjava.net/huamengxing/archive/2010/03/08/314791.html</guid><wfw:comment>http://www.blogjava.net/huamengxing/comments/314791.html</wfw:comment><comments>http://www.blogjava.net/huamengxing/archive/2010/03/08/314791.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huamengxing/comments/commentRss/314791.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huamengxing/services/trackbacks/314791.html</trackback:ping><description><![CDATA[&nbsp;int&nbsp; **p1;&nbsp; //指向指针的指针<br />
&nbsp;&nbsp;&nbsp; int&nbsp; *p2;&nbsp;&nbsp;&nbsp; //指向指针的变量&nbsp; 其中所存储的值为变量的地址，或者变量的地址的地址<br />
&nbsp;&nbsp;&nbsp; int&nbsp; i=3;<br />
&nbsp;&nbsp;&nbsp; p2=&amp;i; <br />
&nbsp;&nbsp;&nbsp; p1=&amp;p2;<br />
&nbsp;printf("Hello World!\n");&nbsp; <br />
&nbsp;printf("%d\n",i);&nbsp; //3<br />
&nbsp;printf("%d\n",**p1); //3<br />
&nbsp;printf("%d\n",*p2); //3<br />
&nbsp;printf("%d\n",&amp;i);&nbsp; //1245044<br />
&nbsp;printf("%d\n",*p1);&nbsp; //1245044<br />
&nbsp;printf("%d\n",p2);&nbsp;&nbsp; //1245044<br />
&nbsp;printf("%d\n",p1);&nbsp;&nbsp; //1245048<br />
&nbsp;printf("%d\n",&amp;p2);&nbsp; //1245048<br />
&nbsp;printf("%d\n",&amp;p1);&nbsp; //1245052<br />
&nbsp;return 0;
<img src ="http://www.blogjava.net/huamengxing/aggbug/314791.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huamengxing/" target="_blank">华梦行</a> 2010-03-08 11:07 <a href="http://www.blogjava.net/huamengxing/archive/2010/03/08/314791.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>The Zen of Python / Python之禅</title><link>http://www.blogjava.net/huamengxing/archive/2009/11/05/301229.html</link><dc:creator>华梦行</dc:creator><author>华梦行</author><pubDate>Thu, 05 Nov 2009 02:54:00 GMT</pubDate><guid>http://www.blogjava.net/huamengxing/archive/2009/11/05/301229.html</guid><wfw:comment>http://www.blogjava.net/huamengxing/comments/301229.html</wfw:comment><comments>http://www.blogjava.net/huamengxing/archive/2009/11/05/301229.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huamengxing/comments/commentRss/301229.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huamengxing/services/trackbacks/301229.html</trackback:ping><description><![CDATA[<table style="width: 100%; table-layout: fixed">
    <tbody>
        <tr>
            <td>
            <div id="blog_text" class="cnt">
            <p>在python中import this就会展示出The Zen of Python如下： <br />
            <br />
            <br />
            The Zen of Python, by Tim Peters <br />
            <br />
            Beautiful is better than ugly. <br />
            Explicit is better than implicit. <br />
            Simple is better than complex. <br />
            Complex is better than complicated. <br />
            Flat is better than nested. <br />
            Sparse is better than dense. <br />
            Readability counts. <br />
            Special cases aren't special enough to break the rules. <br />
            Although practicality beats purity. <br />
            Errors should never pass silently. <br />
            Unless explicitly silenced. <br />
            In the face of ambiguity, refuse the temptation to guess. <br />
            There should be one-- and preferably only one --obvious way to do it. <br />
            Although that way may not be obvious at first unless you're Dutch. <br />
            Now is better than never. <br />
            Although never is often better than *right* now. <br />
            If the implementation is hard to explain, it's a bad idea. <br />
            If the implementation is easy to explain, it may be a good idea. <br />
            Namespaces are one honking great idea -- let's do more of those! <br />
            <br />
            <br />
            从网上搜寻了一下，这被称为python之禅，以下是翻译</p>
            <p><br />
            Python之禅<br />
            赖勇浩翻译</p>
            <p>优美胜于丑陋（Python 以编写优美的代码为目标） <br />
            明了胜于晦涩（优美的代码应当是明了的，命名规范，风格相似） <br />
            简洁胜于复杂（优美的代码应当是简洁的，不要有复杂的内部实现） <br />
            复杂胜于凌乱（如果复杂不可避免，那代码间也不能有难懂的关系，要保持接口简洁） <br />
            扁平胜于嵌套（优美的代码应当是扁平的，不能有太多的嵌套） <br />
            间隔胜于紧凑（优美的代码有适当的间隔，不要奢望一行代码解决问题） <br />
            可读性很重要（优美的代码是可读的） <br />
            即便假借特例的实用性之名，也不可违背这些规则（这些规则至高无上） <br />
            不要包容所有错误，除非你确定需要这样做（精准地捕获异常，不写 except:pass 风格的代码） <br />
            当存在多种可能，不要尝试去猜测 <br />
            而是尽量找一种，最好是唯一一种明显的解决方案（如果不确定，就用穷举法） <br />
            虽然这并不容易，因为你不是 Python 之父（这里的 Dutch 是指 Guido ） <br />
            做也许好过不做，但不假思索就动手还不如不做（动手之前要细思量） <br />
            如果你无法向人描述你的方案，那肯定不是一个好方案；反之亦然（方案测评标准） <br />
            命名空间是一种绝妙的理念，我们应当多加利用（倡导与号召）</p>
            <p>&nbsp;</p>
            <p>The Zen of Python, <br />
            蛇宗三字经 <br />
            <br />
            作者：Tim Peters <br />
            翻译：元创 <br />
            <br />
            <br />
            Beautiful is better than ugly. <br />
            美胜丑 <br />
            Explicit is better than implicit. <br />
            明胜暗 <br />
            Simple is better than complex. <br />
            简胜复 <br />
            Complex is better than complicated. <br />
            复胜杂 <br />
            Flat is better than nested. <br />
            浅胜深 <br />
            Sparse is better than dense. <br />
            疏胜密 <br />
            Readability counts. <br />
            辞达意 <br />
            Special cases aren't special enough to break the rules. <br />
            不逾矩 <br />
            Although practicality beats purity. <br />
            弃至清 <br />
            Errors should never pass silently. <br />
            无阴差 <br />
            Unless explicitly silenced. <br />
            有阳错 <br />
            In the face of ambiguity, refuse the temptation to guess. <br />
            拒疑数 <br />
            There should be one-- and preferably only one --obvious way to do it. <br />
            求完一 <br />
            Although that way may not be obvious at first unless you're Dutch. <br />
            虽不至，向往之 <br />
            Now is better than never. <br />
            敏于行 <br />
            Although never is often better than *right* now. <br />
            戒莽撞 <br />
            If the implementation is hard to explain, it's a bad idea. <br />
            差难言 <br />
            If the implementation is easy to explain, it may be a good idea. <br />
            好易说 <br />
            Namespaces are one honking great idea -- let's do more of those! <br />
            每师出，多有名</p>
            <p><br />
            比较恶搞的是，其实 this 模块的代码完全违背了这些原则，为了方便你查看它的代码，我把它贴出来：<br />
            s = """Gur Mra bs Clguba, ol Gvz Crgref<br />
            <br />
            Ornhgvshy vf orggre guna htyl.<br />
            Rkcyvpvg vf orggre guna vzcyvpvg.<br />
            Fvzcyr vf orggre guna pbzcyrk.<br />
            Pbzcyrk vf orggre guna pbzcyvpngrq.<br />
            Syng vf orggre guna arfgrq.<br />
            Fcnefr vf orggre guna qrafr.<br />
            Ernqnovyvgl pbhagf.<br />
            Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf.<br />
            Nygubhtu cenpgvpnyvgl orngf chevgl.<br />
            Reebef fubhyq arire cnff fvyragyl.<br />
            Hayrff rkcyvpvgyl fvyraprq.<br />
            Va gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff.<br />
            Gurer fubhyq or bar-- naq cersrenoyl bayl bar --boivbhf jnl gb qb vg.<br />
            Nygubhtu gung jnl znl abg or boivbhf ng svefg hayrff lbh'er Qhgpu.<br />
            Abj vf orggre guna arire.<br />
            Nygubhtu arire vf bsgra orggre guna *evtug* abj.<br />
            Vs gur vzcyrzragngvba vf uneq gb rkcynva, vg'f n onq vqrn.<br />
            Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn.<br />
            Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!"""<br />
            <br />
            d = {}<br />
            for c in (65, 97):<br />
            &nbsp;&nbsp;&nbsp; for i in range(26):<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d[chr(i+c)] = chr((i+13) % 26 + c)<br />
            <br />
            print "".join([d.get(c, c) for c in s])</p>
            <p>这段晦涩、复杂、凌乱的代码，莫非是 Tim Peters 提供的反例？</p>
            </div>
            </td>
        </tr>
    </tbody>
</table>
<img src ="http://www.blogjava.net/huamengxing/aggbug/301229.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huamengxing/" target="_blank">华梦行</a> 2009-11-05 10:54 <a href="http://www.blogjava.net/huamengxing/archive/2009/11/05/301229.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>发现一个不错的养生网站  养生之道  www.yszd.org</title><link>http://www.blogjava.net/huamengxing/archive/2009/09/25/296473.html</link><dc:creator>华梦行</dc:creator><author>华梦行</author><pubDate>Fri, 25 Sep 2009 14:25:00 GMT</pubDate><guid>http://www.blogjava.net/huamengxing/archive/2009/09/25/296473.html</guid><wfw:comment>http://www.blogjava.net/huamengxing/comments/296473.html</wfw:comment><comments>http://www.blogjava.net/huamengxing/archive/2009/09/25/296473.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huamengxing/comments/commentRss/296473.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huamengxing/services/trackbacks/296473.html</trackback:ping><description><![CDATA[发现一个不错的养生网站  养生之道  www.yszd.org    ，希望大家喜欢。<img src ="http://www.blogjava.net/huamengxing/aggbug/296473.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huamengxing/" target="_blank">华梦行</a> 2009-09-25 22:25 <a href="http://www.blogjava.net/huamengxing/archive/2009/09/25/296473.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>定义操作系统的版本</title><link>http://www.blogjava.net/huamengxing/archive/2009/03/26/262246.html</link><dc:creator>华梦行</dc:creator><author>华梦行</author><pubDate>Thu, 26 Mar 2009 14:15:00 GMT</pubDate><guid>http://www.blogjava.net/huamengxing/archive/2009/03/26/262246.html</guid><wfw:comment>http://www.blogjava.net/huamengxing/comments/262246.html</wfw:comment><comments>http://www.blogjava.net/huamengxing/archive/2009/03/26/262246.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huamengxing/comments/commentRss/262246.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huamengxing/services/trackbacks/262246.html</trackback:ping><description><![CDATA[ #define   WINVER   0x0050   <br />#define   WINVER   0x0500，这个表示是为Windows   2000编译，不保证Windows   98/NT4可以正常运行   <br /><br />Windows   Server   2003   <br />  WINVER&gt;=0x0502   <br />      <br />  Windows   XP     <br />  WINVER&gt;=0x0501   <br />      <br />  Windows   2000   <br />  WINVER&gt;=0x0500   <br />      <br />  Windows   NT   4.0   <br />  WINVER&gt;=0x0400   <br />      <br />  Windows   Me   <br />  WINVER&gt;=0x0500   <br />      <br />  Windows   98   <br />  WINVER&gt;=0x0410   <br />      <br />  Windows   95   <br />  WINVER&gt;=0x0400   <br />      <br /><img src ="http://www.blogjava.net/huamengxing/aggbug/262246.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huamengxing/" target="_blank">华梦行</a> 2009-03-26 22:15 <a href="http://www.blogjava.net/huamengxing/archive/2009/03/26/262246.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>划线</title><link>http://www.blogjava.net/huamengxing/archive/2009/03/24/261722.html</link><dc:creator>华梦行</dc:creator><author>华梦行</author><pubDate>Tue, 24 Mar 2009 08:25:00 GMT</pubDate><guid>http://www.blogjava.net/huamengxing/archive/2009/03/24/261722.html</guid><wfw:comment>http://www.blogjava.net/huamengxing/comments/261722.html</wfw:comment><comments>http://www.blogjava.net/huamengxing/archive/2009/03/24/261722.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huamengxing/comments/commentRss/261722.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huamengxing/services/trackbacks/261722.html</trackback:ping><description><![CDATA[
		<p> // TODO: Add your message handler code here and/or call default<br /> /*HDC hdc;<br /> hdc=::GetDC(m_hWnd);<br /> MoveToEx(hdc,m_ptOrigin.x,m_ptOrigin.y,NULL);<br /> LineTo(hdc,point.x,point.y);<br /> ::ReleaseDC(m_hWnd,hdc);*/<br /> /*CDC *pDC=GetDC();<br /> pDC-&gt;MoveTo(m_ptOrigin);<br /> pDC-&gt;LineTo(point);<br /> ReleaseDC(pDC);*/</p>
		<p> //CClientDC dc(this);<br /> /*CClientDC dc(GetParent());<br /> dc.MoveTo(m_ptOrigin);<br /> dc.LineTo(point);*/</p>
		<p> //CWindowDC dc(this);<br /> //CWindowDC dc(GetParent());<br /> /*CWindowDC dc(GetDesktopWindow());<br /> dc.MoveTo(m_ptOrigin);<br /> dc.LineTo(point);*/<br /> /*CPen pen(PS_DOT,1,RGB(0,255,0));<br /> CClientDC dc(this);<br /> CPen *pOldPen=dc.SelectObject(&amp;pen);<br /> dc.MoveTo(m_ptOrigin);<br /> dc.LineTo(point);<br /> dc.SelectObject(pOldPen);*/<br />// CBrush brush(RGB(255,0,0));</p>
		<p> /*CBitmap bitmap;<br /> bitmap.LoadBitmap(IDB_BITMAP1);<br /> CBrush brush(&amp;bitmap);*/<br /> /*CClientDC dc(this);<br /> //dc.FillRect(CRect(m_ptOrigin,point),&amp;brush);<br /> CBrush *pBrush=CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));<br /> CBrush *pOldBrush=dc.SelectObject(pBrush);<br /> dc.Rectangle(CRect(m_ptOrigin,point));<br /> dc.SelectObject(pOldBrush);*/<br /> m_bDraw=FALSE;<br /> CView::OnLButtonUp(nFlags, point);</p>
<img src ="http://www.blogjava.net/huamengxing/aggbug/261722.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huamengxing/" target="_blank">华梦行</a> 2009-03-24 16:25 <a href="http://www.blogjava.net/huamengxing/archive/2009/03/24/261722.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C进制转换</title><link>http://www.blogjava.net/huamengxing/archive/2009/03/19/260815.html</link><dc:creator>华梦行</dc:creator><author>华梦行</author><pubDate>Thu, 19 Mar 2009 08:37:00 GMT</pubDate><guid>http://www.blogjava.net/huamengxing/archive/2009/03/19/260815.html</guid><wfw:comment>http://www.blogjava.net/huamengxing/comments/260815.html</wfw:comment><comments>http://www.blogjava.net/huamengxing/archive/2009/03/19/260815.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huamengxing/comments/commentRss/260815.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huamengxing/services/trackbacks/260815.html</trackback:ping><description><![CDATA[
		<p>#include &lt;iostream.h&gt;<br />#include &lt;string&gt;<br />char* strToBinary(int x);<br />char* strToHex(int i);<br />char* transToGKB(char *t);</p>
		<p>int main ()</p>
		<p>{<br />char *p=strToBinary(233);<br />//cout&lt;&lt;p;</p>
		<p>//cout&lt;&lt;strToHex(233);<br />cout&lt;&lt;transToGKB("商");<br />return 0;<br />}<br />char* transToGKB(char *t){<br /> int res=0;<br />   int intlen;<br />   intlen=strlen(t);<br />   if(intlen&gt;1){<br />    char *result=new char[5];<br />   int i=0;<br /> if(0&gt;t[0]){<br />    res=256+t[0];<br />  }<br /> char *p1=strToHex(res);<br /> if(0&gt;t[1]){<br />  res=256+t[1];<br /> }<br /> char *p2=strToHex(res);<br /> result=p1;<br /> result[2]=p2[0];<br /> result[3]=p2[1]; <br /> result[4]='\0'; <br /> return result;<br /> }<br />   else{<br />    //if(t[0]&gt;64)<br />    char * p=new char[3];<br />    p=strToHex(t[0]);<br />    p[2]='\0';<br />    return  p;<br />   }</p>
		<p>}</p>
		<p> </p>
		<p>//数字转为二进制（255以内的正数）<br />char* strToBinary(int i){<br /> char *result=new   char[9];<br /> int n=1;<br /> int m;<br /> int c=0;<br /> int j=8;<br /> for(c=0;c&lt;8;c++){<br />  m=i%2;<br />  j=j-1;<br />  i=n=i/2;<br />  if(n&gt;=0){<br />   if (m&gt;0){<br />    result[j]='1';<br />   }else<br />   {<br />    result[j]='0';<br />   } <br />  }<br />  <br /> }<br /> result[8]='\0';<br /> <br />// cout&lt;&lt;result;<br /> return result;<br />}<br />//数字转为十六进制（255以内的正数）<br />char* strToHex(int i){<br /> char *result=new   char[3];<br /> int n=1;<br /> int m;<br /> int c=0;<br /> int j=2;<br /> for(c=0;c&lt;2;c++){<br />  m=i%16;<br />  j=j-1;<br />  i=n=i/16;<br />  if(n&gt;=0){<br />   if (m&gt;0){<br />    if (m==1){<br />                  result[j]='1';<br />    }<br />    else if (m==2){<br />     result[j]='2';<br />    }<br />    else if (m==3){<br />     result[j]='3';<br />    }<br />    else if (m==4){<br />     result[j]='4';<br />    }<br />    else if (m==5){<br />     result[j]='5';<br />    }<br />    else if (m==6){<br />     result[j]='6';<br />    }<br />    else if (m==7){<br />     result[j]='7';<br />    }<br />    else if (m==8){<br />     result[j]='8';<br />    }<br />    else if (m==9){<br />     result[j]='9';<br />    }<br />    else if (m==10){<br />     result[j]='A';<br />    }<br />    else if (m==11){<br />     result[j]='B';<br />    }<br />    else if (m==12){<br />     result[j]='C';<br />    }<br />    else if (m==13){<br />     result[j]='D';<br />    }<br />    else if (m==14){<br />     result[j]='E';<br />    }<br />    else if (m==15){<br />     result[j]='F';<br />    }<br />   }else<br />   {<br />    result[j]='0';<br />   } <br />  }<br /> }<br /> result[2]='\0';<br /> return result;<br />}</p>
<img src ="http://www.blogjava.net/huamengxing/aggbug/260815.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huamengxing/" target="_blank">华梦行</a> 2009-03-19 16:37 <a href="http://www.blogjava.net/huamengxing/archive/2009/03/19/260815.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C 进制转换</title><link>http://www.blogjava.net/huamengxing/archive/2009/03/17/260297.html</link><dc:creator>华梦行</dc:creator><author>华梦行</author><pubDate>Tue, 17 Mar 2009 09:47:00 GMT</pubDate><guid>http://www.blogjava.net/huamengxing/archive/2009/03/17/260297.html</guid><wfw:comment>http://www.blogjava.net/huamengxing/comments/260297.html</wfw:comment><comments>http://www.blogjava.net/huamengxing/archive/2009/03/17/260297.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huamengxing/comments/commentRss/260297.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huamengxing/services/trackbacks/260297.html</trackback:ping><description><![CDATA[
		<p>#include &lt;iostream.h&gt;</p>
		<p>#include &lt;string&gt;<br />void yihuo(char *t,int n, int m);<br />void  myToBinary();<br />void transToGKB(char *t);<br />void  myToHex();<br />int main(){<br />//cout&lt;&lt;"GOOD";<br />int i=122;<br />int j=233;<br />int m=j^i;<br /> char t[128]={0xC9,0xCC,0xC9,0xCC,0xC9,0xCC,'\0',0xC9,0xCC,0xC9,0xCC};<br />yihuo(t,0, 2);<br />// transToGKB(t);<br />//cout&lt;&lt;m;<br />//yihuo(2, 3);<br />//myToHex();<br />// myToBinary();<br />cout&lt;&lt;endl;<br />return 0;<br />}<br />//进制之间的转换<br />  // 字符串传为16进制<br />void  myToHex(){<br /> char c[] = "CC";<br /> unsigned long tt= strtoul(c, NULL, 16);<br />cout&lt;&lt;strtol(c, NULL, 16);</p>
		<p>}</p>
		<p>// 字符串传为16进制<br />void  myToBinary(){<br /> char c[] = "10000000";<br />// unsigned long tt= strtoul(c, NULL, 2);<br /> cout&lt;&lt;strtol(c, NULL, 2);<br /> <br /> <br />}<br />//汉字的转换， 16进制转换为汉字<br />void transToGKB(char *t){</p>
		<p> <br /> // char *t="商户";<br /> // CharN<br /> //如果是负数，则转为正整数<br /> // if(0&gt;t[0]){<br /> //    res=256+t[0];<br /> // }<br /> int j=t[0];<br /> cout&lt;&lt;t&lt;&lt;endl;</p>
		<p>}</p>
		<p>
				<br />void yihuo(char *t,int n, int m) {</p>
		<p> char *tt="商户说的算";<br />    //转成数字并且保存到数组，然后求异或</p>
		<p> //求的长度<br />const int mylen=strlen(tt)+1;<br />char mysplit[1000];<br />//循环对这个整形数组进行赋值<br />int i=0;<br />for(i&lt;0;i&lt;mylen-1;i++){<br /> if (tt[i]&lt;0){<br />mysplit[i]=256+tt[i];<br /> }else<br /> {<br />mysplit[i]=tt[i];<br /> }<br />}<br />int result=mysplit[n-1];<br />int j;<br />for(j=n;j&lt;n+m;j++){<br /> result=result^mysplit[n];<br /> cout&lt;&lt;"L"&lt;&lt;endl;<br />cout&lt;&lt;mysplit[n];<br /> cout&lt;&lt;"M"&lt;&lt;endl;</p>
		<p>}</p>
		<p>//进行遍历求异或<br />mysplit[mylen-1]='\0';<br />cout&lt;&lt;mysplit;</p>
		<p>cout&lt;&lt;"ee";<br />if(result&lt;0)<br />result=256+result;<br />cout&lt;&lt;result;<br /> //int j=t[0];<br />// cout&lt;&lt;t&lt;&lt;endl;</p>
		<p> }</p>
		<p> </p>
<img src ="http://www.blogjava.net/huamengxing/aggbug/260297.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huamengxing/" target="_blank">华梦行</a> 2009-03-17 17:47 <a href="http://www.blogjava.net/huamengxing/archive/2009/03/17/260297.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>activex</title><link>http://www.blogjava.net/huamengxing/archive/2009/03/11/259232.html</link><dc:creator>华梦行</dc:creator><author>华梦行</author><pubDate>Wed, 11 Mar 2009 14:27:00 GMT</pubDate><guid>http://www.blogjava.net/huamengxing/archive/2009/03/11/259232.html</guid><wfw:comment>http://www.blogjava.net/huamengxing/comments/259232.html</wfw:comment><comments>http://www.blogjava.net/huamengxing/archive/2009/03/11/259232.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huamengxing/comments/commentRss/259232.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huamengxing/services/trackbacks/259232.html</trackback:ping><description><![CDATA[
		<p>Private Sub UserControl_ReadProperties(PropBag As PropertyBag)</p>
		<p>
				<br /> Text1.Text = PropBag.ReadProperty("RecordSource", _<br />       m_def_recordSource)<br />  Text2.Text = PropBag.ReadProperty _<br />   ("ConnectionString", m_def_connectionString)</p>
		<p>
				<br />End Sub<br /></p>
<img src ="http://www.blogjava.net/huamengxing/aggbug/259232.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huamengxing/" target="_blank">华梦行</a> 2009-03-11 22:27 <a href="http://www.blogjava.net/huamengxing/archive/2009/03/11/259232.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>指针处理</title><link>http://www.blogjava.net/huamengxing/archive/2009/03/10/258922.html</link><dc:creator>华梦行</dc:creator><author>华梦行</author><pubDate>Tue, 10 Mar 2009 13:45:00 GMT</pubDate><guid>http://www.blogjava.net/huamengxing/archive/2009/03/10/258922.html</guid><wfw:comment>http://www.blogjava.net/huamengxing/comments/258922.html</wfw:comment><comments>http://www.blogjava.net/huamengxing/archive/2009/03/10/258922.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huamengxing/comments/commentRss/258922.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huamengxing/services/trackbacks/258922.html</trackback:ping><description><![CDATA[
		<p>int main(void) <br />{ <br />   int m=4;<br />   int nn;<br />   int  *n;<br />   int *s; <br />   int *p;<br />   int *q;<br />   n=&amp;m;<br />   <br />  nn=n;<br />   q=n;<br />  s=nn;<br />   printf("%08x",*s);</p>
		<p>
				<br />   return 0; <br />}</p>
<img src ="http://www.blogjava.net/huamengxing/aggbug/258922.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huamengxing/" target="_blank">华梦行</a> 2009-03-10 21:45 <a href="http://www.blogjava.net/huamengxing/archive/2009/03/10/258922.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>三个特殊的硬件地址</title><link>http://www.blogjava.net/huamengxing/archive/2009/03/10/258851.html</link><dc:creator>华梦行</dc:creator><author>华梦行</author><pubDate>Tue, 10 Mar 2009 08:51:00 GMT</pubDate><guid>http://www.blogjava.net/huamengxing/archive/2009/03/10/258851.html</guid><wfw:comment>http://www.blogjava.net/huamengxing/comments/258851.html</wfw:comment><comments>http://www.blogjava.net/huamengxing/archive/2009/03/10/258851.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huamengxing/comments/commentRss/258851.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huamengxing/services/trackbacks/258851.html</trackback:ping><description><![CDATA[
		<p>0xFFFFFF20  数据输入缓冲区<br />0xFFFFFF24  输出数据缓冲区   <br />0xFFFFFF28  控制寄存器</p>
<img src ="http://www.blogjava.net/huamengxing/aggbug/258851.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huamengxing/" target="_blank">华梦行</a> 2009-03-10 16:51 <a href="http://www.blogjava.net/huamengxing/archive/2009/03/10/258851.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C程序的内存分布</title><link>http://www.blogjava.net/huamengxing/archive/2009/03/10/258814.html</link><dc:creator>华梦行</dc:creator><author>华梦行</author><pubDate>Tue, 10 Mar 2009 07:40:00 GMT</pubDate><guid>http://www.blogjava.net/huamengxing/archive/2009/03/10/258814.html</guid><wfw:comment>http://www.blogjava.net/huamengxing/comments/258814.html</wfw:comment><comments>http://www.blogjava.net/huamengxing/archive/2009/03/10/258814.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huamengxing/comments/commentRss/258814.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huamengxing/services/trackbacks/258814.html</trackback:ping><description><![CDATA[
		<div>
				<div class="m_l_cont_text">
						<div>1.<font color="#ff0000">程序段</font>:程序段为程序代码在内存中的映射.一个程序可以在内存中多有个副本.</div>
						<div>2.<font color="#ff0000">初始化过的数据</font>:在程序运行值初已经对变量进行初始化的</div>
						<div>3.<font color="#ff0000">未初始化过的数据</font>:在程序运行初未对变量进行初始化的数据</div>
						<div>4.<font color="#ff0000">堆(stack)</font><font color="#000000">:</font>存储局部,临时变量,在程序块开始时自动分配内存,结束时自动释放内存.存储函数的返回指针.</div>
						<div>5.<font color="#ff0000">栈(heap)</font><font color="#000000">:</font>存储动态内存分配,需要程序员手工分配,手工释放.</div>
						<div> </div>
						<div>
								<img src="http://blog.chinaunix.net/photo/85561_081230114738.jpg" />
						</div>
						<div>
								<p style="MARGIN: 5px; LINE-HEIGHT: 150%">
										<code>
												<span style="COLOR: #000000">
														<span style="COLOR: #0000cc">#</span>
														<span style="COLOR: #ff0000">include</span>
														<span style="COLOR: #0000cc">&lt;</span>stdio<span style="COLOR: #0000cc">.</span>h<span style="COLOR: #0000cc">&gt;</span><br /><br /><span style="COLOR: #0000ff">int</span> g1<span style="COLOR: #0000cc">=</span>0<span style="COLOR: #0000cc">,</span> g2<span style="COLOR: #0000cc">=</span>0<span style="COLOR: #0000cc">,</span> g3<span style="COLOR: #0000cc">=</span>0<span style="COLOR: #0000cc">;</span><br /><br /><span style="COLOR: #0000ff">int</span><span style="COLOR: #ff0000">max</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #0000ff">int</span> i<span style="COLOR: #0000cc">)</span><br /><span style="COLOR: #0000cc">{</span><br />    <span style="COLOR: #0000ff">int</span> m1<span style="COLOR: #0000cc">=</span>0<span style="COLOR: #0000cc">,</span>m2<span style="COLOR: #0000cc">,</span>m3<span style="COLOR: #0000cc">=</span>0<span style="COLOR: #0000cc">,</span><span style="COLOR: #0000cc">*</span>p_max<span style="COLOR: #0000cc">;</span><br />    <span style="COLOR: #0000ff">static</span> n1_max<span style="COLOR: #0000cc">=</span>0<span style="COLOR: #0000cc">,</span>n2_max<span style="COLOR: #0000cc">,</span>n3_max<span style="COLOR: #0000cc">=</span>0<span style="COLOR: #0000cc">;</span><br />    p_max <span style="COLOR: #0000cc">=</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #0000cc">*</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #ff0000">malloc</span><span style="COLOR: #0000cc">(</span>10<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br />    <span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"打印max程序地址\n"</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br />    <span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"in max: 0x%08x\n\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #ff0000">max</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br />    <span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"打印max传入参数地址\n"</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br />    <span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"in max: 0x%08x\n\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #0000cc">&amp;</span>i<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br />    <span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"打印max函数中静态变量地址\n"</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br />    <span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"0x%08x\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #0000cc">&amp;</span>n1_max<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><span style="COLOR: #ff9900">//打印各本地变量的内存地址<br /></span>    <span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"0x%08x\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #0000cc">&amp;</span>n2_max<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br />    <span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"0x%08x\n\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #0000cc">&amp;</span>n3_max<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br />    <span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"打印max函数中局部变量地址\n"</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br />    <span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"0x%08x\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #0000cc">&amp;</span>m1<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><span style="COLOR: #ff9900">//打印各本地变量的内存地址<br /></span>    <span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"0x%08x\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #0000cc">&amp;</span>m2<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br />    <span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"0x%08x\n\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #0000cc">&amp;</span>m3<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br />    <span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"打印max函数中malloc分配地址\n"</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br />    <span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"0x%08x\n\n"</span><span style="COLOR: #0000cc">,</span>p_max<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><span style="COLOR: #ff9900">//打印各本地变量的内存地址<br /></span><br />    <span style="COLOR: #0000ff">if</span><span style="COLOR: #0000cc">(</span>i<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000ff">return</span> 1<span style="COLOR: #0000cc">;</span><br />    <span style="COLOR: #0000ff">else</span><span style="COLOR: #0000ff">return</span> 0<span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #0000cc">}</span><br /><br /><span style="COLOR: #0000ff">int</span> main<span style="COLOR: #0000cc">(</span><span style="COLOR: #0000ff">int</span> argc<span style="COLOR: #0000cc">,</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #0000cc">*</span><span style="COLOR: #0000cc">*</span>argv<span style="COLOR: #0000cc">)</span><br /><span style="COLOR: #0000cc">{</span><br /><span style="COLOR: #0000ff">static</span><span style="COLOR: #0000ff">int</span> s1<span style="COLOR: #0000cc">=</span>0<span style="COLOR: #0000cc">,</span> s2<span style="COLOR: #0000cc">,</span> s3<span style="COLOR: #0000cc">=</span>0<span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #0000ff">int</span> v1<span style="COLOR: #0000cc">=</span>0<span style="COLOR: #0000cc">,</span> v2<span style="COLOR: #0000cc">,</span> v3<span style="COLOR: #0000cc">=</span>0<span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #0000ff">int</span><span style="COLOR: #0000cc">*</span>p<span style="COLOR: #0000cc">;</span>    <br />p <span style="COLOR: #0000cc">=</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #0000cc">*</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #ff0000">malloc</span><span style="COLOR: #0000cc">(</span>10<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"打印各全局变量(已初始化)的内存地址\n"</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"0x%08x\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #0000cc">&amp;</span>g1<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><span style="COLOR: #ff9900">//打印各全局变量的内存地址<br /></span><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"0x%08x\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #0000cc">&amp;</span>g2<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"0x%08x\n\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #0000cc">&amp;</span>g3<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"======================\n"</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"打印程序初始程序main地址\n"</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"main: 0x%08x\n\n"</span><span style="COLOR: #0000cc">,</span> main<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"打印主参地址\n"</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"argv: 0x%08x\n\n"</span><span style="COLOR: #0000cc">,</span>argv<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"打印各静态变量的内存地址\n"</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"0x%08x\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #0000cc">&amp;</span>s1<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><span style="COLOR: #ff9900">//打印各静态变量的内存地址<br /></span><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"0x%08x\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #0000cc">&amp;</span>s2<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"0x%08x\n\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #0000cc">&amp;</span>s3<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"打印各局部变量的内存地址\n"</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"0x%08x\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #0000cc">&amp;</span>v1<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><span style="COLOR: #ff9900">//打印各本地变量的内存地址<br /></span><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"0x%08x\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #0000cc">&amp;</span>v2<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"0x%08x\n\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #0000cc">&amp;</span>v3<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"打印malloc分配的堆地址\n"</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"malloc: 0x%08x\n\n"</span><span style="COLOR: #0000cc">,</span>p<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"======================\n"</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br />    <span style="COLOR: #ff0000">max</span><span style="COLOR: #0000cc">(</span>v1<span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"======================\n"</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"打印子函数起始地址\n"</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #ff0000">printf</span><span style="COLOR: #0000cc">(</span><span style="COLOR: #ff00ff">"max: 0x%08x\n\n"</span><span style="COLOR: #0000cc">,</span><span style="COLOR: #ff0000">max</span><span style="COLOR: #0000cc">)</span><span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #0000ff">return</span> 0<span style="COLOR: #0000cc">;</span><br /><span style="COLOR: #0000cc">}</span></span>
										</code>
								</p>
								<p style="MARGIN: 5px; LINE-HEIGHT: 150%">
										<code>
												<span style="COLOR: #000000">
														<span style="COLOR: #0000cc">
														</span>
												</span>
										</code> </p>
								<p style="MARGIN: 5px; LINE-HEIGHT: 150%">
										<code>
												<span style="COLOR: #000000">
														<span style="COLOR: #0000cc">
																<font color="#000000">这个程序可以大致查看整个程序在内存中的分配情况:<br />可以看出,传入的参数,局部变量,都是在栈顶分布,随着子函数的增多而向下增长.<br />函数的调用地址(函数运行代码),全局变量,静态变量都是在分配内存的低部存在,而malloc分配的堆则存在于这些内存之上,并向上生长</font>
														</span>
												</span>
										</code>
								</p>
						</div>
				</div>
		</div>
<img src ="http://www.blogjava.net/huamengxing/aggbug/258814.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huamengxing/" target="_blank">华梦行</a> 2009-03-10 15:40 <a href="http://www.blogjava.net/huamengxing/archive/2009/03/10/258814.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>