﻿<?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>C++博客-乔栋的佛国-随笔分类-C的游乐园</title><link>http://www.cppblog.com/qiaodong/category/2992.html</link><description>耶路撒冷对你来说意味着什么？</description><language>zh-cn</language><lastBuildDate>Mon, 26 May 2008 08:23:32 GMT</lastBuildDate><pubDate>Mon, 26 May 2008 08:23:32 GMT</pubDate><ttl>60</ttl><item><title>C 程序设计经典书籍</title><link>http://www.cppblog.com/qiaodong/archive/2007/06/07/25706.html</link><dc:creator>乔栋</dc:creator><author>乔栋</author><pubDate>Thu, 07 Jun 2007 01:56:00 GMT</pubDate><guid>http://www.cppblog.com/qiaodong/archive/2007/06/07/25706.html</guid><wfw:comment>http://www.cppblog.com/qiaodong/comments/25706.html</wfw:comment><comments>http://www.cppblog.com/qiaodong/archive/2007/06/07/25706.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qiaodong/comments/commentRss/25706.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qiaodong/services/trackbacks/25706.html</trackback:ping><description><![CDATA[<div id=OutBox>
<div style="FLOAT: left; WIDTH: 69%">
<table cellSpacing=0 cellPadding=0 width="100%" border=0>
    <tbody>
        <tr>
            <td>
            <div style="FLOAT: left; PADDING-TOP: 20px">
            <div style="FONT-WEIGHT: bold; FONT-SIZE: 16px; FLOAT: left; PADDING-BOTTOM: 10px; WIDTH: 100%">荣耀：C程序设计之四书五经 </div>
            <div class=line1></div>
            </div>
            </td>
        </tr>
        <tr>
            <td style="PADDING-LEFT: 20px"><font color=green>来自:</font><a href="http://club.book.csdn.net/people/bookread.html">bookread</a> </td>
        </tr>
        <tr>
            <td style="PADDING-LEFT: 30px"></td>
        </tr>
        <tr>
            <td style="COLOR: gray; HEIGHT: 14px; TEXT-ALIGN: right">此书架对<span id=qq>287</span>人里的<span id=pp>208</span>人有用
            <div class=cntNav style="FLOAT: left; WIDTH: 100%">对你<span class=act> <a id=p5 onclick="SubInfo(1,this.id,event);return false;" href="http://club.book.csdn.net/people/mylist5.html#">有用</a></span> <span class=act><a id=5 onclick="SubInfo(0,this.id,event);return false;" href="http://club.book.csdn.net/people/mylist5.html#">无用</a></span> </div>
            </td>
        </tr>
    </tbody>
</table>
<table cellSpacing=0 cellPadding=0 width="100%" border=0>
    <tbody>
        <tr>
            <td class=line1>&nbsp; </td>
        </tr>
        <tr>
            <td><span id=__listBook__>
            <table cellSpacing=0 cellPadding=0 width="100%" border=0>
                <tbody>
                    <tr>
                        <td style="WIDTH: 90px" rowSpan=3><a href="http://club.book.csdn.net/book/7703.html"><img height=90 alt="" src="http://club.book.csdn.net/pic/7703.jpg" width=70></a></td>
                        <td style="PADDING-LEFT: 20px; WIDTH: 650px" align=left><a href="http://club.book.csdn.net/book/7703.html">C程序设计教程</a>&nbsp;</td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px" align=left>（美）H.M.Deitel等著 薛万鹏等译 / 2000年7月 / 机械工业出版社 / 33元 / 787*1092 1/16 / </td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px; COLOR: gray; TEXT-INDENT: 2em" align=left></td>
                    </tr>
                    <tr>
                        <td align=left><br></td>
                    </tr>
                    <tr>
                        <td class=z2 style="PADDING-BOTTOM: 10px; WIDTH: 100%" colSpan=2>&nbsp; </td>
                    </tr>
                </tbody>
            </table>
            <table cellSpacing=0 cellPadding=0 width="100%" border=0>
                <tbody>
                    <tr>
                        <td style="WIDTH: 90px" rowSpan=3><a href="http://club.book.csdn.net/book/64.html"><img height=90 alt="" src="http://club.book.csdn.net/pic/64.jpg" width=70></a></td>
                        <td style="PADDING-LEFT: 20px; WIDTH: 650px" align=left><a href="http://club.book.csdn.net/book/64.html">C陷阱与缺陷</a>&nbsp;</td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px" align=left>Andrew Koenig著 高巍译 / 2002年11月 / 人民邮电出版社 / 30元 / 720*980 1/16 / </td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px; COLOR: gray; TEXT-INDENT: 2em" align=left></td>
                    </tr>
                    <tr>
                        <td align=left><br></td>
                    </tr>
                    <tr>
                        <td class=z2 style="PADDING-BOTTOM: 10px; WIDTH: 100%" colSpan=2>&nbsp; </td>
                    </tr>
                </tbody>
            </table>
            <table cellSpacing=0 cellPadding=0 width="100%" border=0>
                <tbody>
                    <tr>
                        <td style="WIDTH: 90px" rowSpan=3><a href="http://club.book.csdn.net/book/12674.html"><img height=90 alt="" src="http://club.book.csdn.net/pic/12674.jpg" width=70></a></td>
                        <td style="PADDING-LEFT: 20px; WIDTH: 650px" align=left><a href="http://club.book.csdn.net/book/12674.html">C语言接口与实现——创建可重用软件的技术</a>&nbsp;</td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px" align=left>[美]汉森 著，傅蓉等 译 / 01 1 2004 12:00AM / 机械工业出版社 / 35元 / 787*1092 1/16 / </td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px; COLOR: gray; TEXT-INDENT: 2em" align=left></td>
                    </tr>
                    <tr>
                        <td align=left><br></td>
                    </tr>
                    <tr>
                        <td class=z2 style="PADDING-BOTTOM: 10px; WIDTH: 100%" colSpan=2>&nbsp; </td>
                    </tr>
                </tbody>
            </table>
            <table cellSpacing=0 cellPadding=0 width="100%" border=0>
                <tbody>
                    <tr>
                        <td style="WIDTH: 90px" rowSpan=3><a href="http://club.book.csdn.net/book/1655.html"><img height=90 alt="" src="http://club.book.csdn.net/pic/1655.jpg" width=70></a></td>
                        <td style="PADDING-LEFT: 20px; WIDTH: 650px" align=left><a href="http://club.book.csdn.net/book/1655.html">C语言参考手册（原书第5版）</a>&nbsp;</td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px" align=left>（美）Samuel P.Harbison III/Guy L.Steele Jr.著 邱仲潘等译 / 2003年8月 / 机械工业出版社 / 39元 / 787*1092 1/16 / </td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px; COLOR: gray; TEXT-INDENT: 2em" align=left></td>
                    </tr>
                    <tr>
                        <td align=left><br></td>
                    </tr>
                    <tr>
                        <td class=z2 style="PADDING-BOTTOM: 10px; WIDTH: 100%" colSpan=2>&nbsp; </td>
                    </tr>
                </tbody>
            </table>
            <table cellSpacing=0 cellPadding=0 width="100%" border=0>
                <tbody>
                    <tr>
                        <td style="WIDTH: 90px" rowSpan=3><a href="http://club.book.csdn.net/book/19109.html"><img height=90 alt="" src="http://club.book.csdn.net/pic/19109.jpg" width=70></a></td>
                        <td style="PADDING-LEFT: 20px; WIDTH: 650px" align=left><a href="http://club.book.csdn.net/book/19109.html">C语言参考手册（第五版）（英文版）</a>&nbsp;</td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px" align=left>哈比森，斯蒂尔 著 / 06 1 2003 12:00AM / 人民邮电出版社 / 45元 / 16开 / </td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px; COLOR: gray; TEXT-INDENT: 2em" align=left></td>
                    </tr>
                    <tr>
                        <td align=left><br></td>
                    </tr>
                    <tr>
                        <td class=z2 style="PADDING-BOTTOM: 10px; WIDTH: 100%" colSpan=2>&nbsp; </td>
                    </tr>
                </tbody>
            </table>
            <table cellSpacing=0 cellPadding=0 width="100%" border=0>
                <tbody>
                    <tr>
                        <td style="WIDTH: 90px" rowSpan=3><a href="http://club.book.csdn.net/book/2529.html"><img height=90 alt="" src="http://club.book.csdn.net/pic/2529.jpg" width=70></a></td>
                        <td style="PADDING-LEFT: 20px; WIDTH: 650px" align=left><a href="http://club.book.csdn.net/book/2529.html">C专家编程</a>&nbsp;</td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px" align=left>Peter Van Der Linden著 徐波译 / 2002年12月 / 人民邮电出版社 / 40元 / 800*1000 1/16 / </td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px; COLOR: gray; TEXT-INDENT: 2em" align=left></td>
                    </tr>
                    <tr>
                        <td align=left><br></td>
                    </tr>
                    <tr>
                        <td class=z2 style="PADDING-BOTTOM: 10px; WIDTH: 100%" colSpan=2>&nbsp; </td>
                    </tr>
                </tbody>
            </table>
            <table cellSpacing=0 cellPadding=0 width="100%" border=0>
                <tbody>
                    <tr>
                        <td style="WIDTH: 90px" rowSpan=3><a href="http://club.book.csdn.net/book/12720.html"><img height=90 alt="" src="http://club.book.csdn.net/pic/12720.jpg" width=70></a></td>
                        <td style="PADDING-LEFT: 20px; WIDTH: 650px" align=left><a href="http://club.book.csdn.net/book/12720.html">C程序设计语言（第2版&#183;新版）习题解答</a>&nbsp;</td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px" align=left>[美]汤朵，[美]吉米拜尔 著，杨涛等 译 / 01 1 2004 12:00AM / 机械工业出版社 / 15元 / 787*1092 1/16 / </td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px; COLOR: gray; TEXT-INDENT: 2em" align=left></td>
                    </tr>
                    <tr>
                        <td align=left><br></td>
                    </tr>
                    <tr>
                        <td class=z2 style="PADDING-BOTTOM: 10px; WIDTH: 100%" colSpan=2>&nbsp; </td>
                    </tr>
                </tbody>
            </table>
            <table cellSpacing=0 cellPadding=0 width="100%" border=0>
                <tbody>
                    <tr>
                        <td style="WIDTH: 90px" rowSpan=3><a href="http://club.book.csdn.net/book/12645.html"><img height=90 alt="" src="http://club.book.csdn.net/pic/12645.jpg" width=70></a></td>
                        <td style="PADDING-LEFT: 20px; WIDTH: 650px" align=left><a href="http://club.book.csdn.net/book/12645.html">C程序设计语言(第2版&#183;新版)</a>&nbsp;</td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px" align=left>（美）克尼汉，（美）里奇 著，徐宝文，李志 译 / 01 1 2004 12:00AM / 机械工业出版社 / 30元 / 787*1092 1/16 / </td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px; COLOR: gray; TEXT-INDENT: 2em" align=left></td>
                    </tr>
                    <tr>
                        <td align=left><br></td>
                    </tr>
                    <tr>
                        <td class=z2 style="PADDING-BOTTOM: 10px; WIDTH: 100%" colSpan=2>&nbsp; </td>
                    </tr>
                </tbody>
            </table>
            <table cellSpacing=0 cellPadding=0 width="100%" border=0>
                <tbody>
                    <tr>
                        <td style="WIDTH: 90px" rowSpan=3><a href="http://club.book.csdn.net/book/18283.html"><img height=90 alt="" src="http://club.book.csdn.net/pic/18283.jpg" width=70></a></td>
                        <td style="PADDING-LEFT: 20px; WIDTH: 650px" align=left><a href="http://club.book.csdn.net/book/18283.html">C程序设计语言第二版习题解答（第二版)（英文影印版）</a>&nbsp;</td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px" align=left>Clovis L.Tondo,Scott E.Gimpel / 2000-3-1 / 清华大学出版社 / 12元 / </td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px; COLOR: gray; TEXT-INDENT: 2em" align=left></td>
                    </tr>
                    <tr>
                        <td align=left><br></td>
                    </tr>
                    <tr>
                        <td class=z2 style="PADDING-BOTTOM: 10px; WIDTH: 100%" colSpan=2>&nbsp; </td>
                    </tr>
                </tbody>
            </table>
            <table cellSpacing=0 cellPadding=0 width="100%" border=0>
                <tbody>
                    <tr>
                        <td style="WIDTH: 90px" rowSpan=3><a href="http://club.book.csdn.net/book/11250.html"><img height=90 alt="" src="http://club.book.csdn.net/pic/11250.jpg" width=70></a></td>
                        <td style="PADDING-LEFT: 20px; WIDTH: 650px" align=left><a href="http://club.book.csdn.net/book/11250.html">C程序设计语言</a>&nbsp;</td>
                    </tr>
                    <tr>
                        <td style="PADDING-LEFT: 20px" align=left>Brian W.Kernighan / 1997年3月 / 清华大学出版社 / 0元 / 850*1168 1/32 / </td>
                    </tr>
                </tbody>
            </table>
            </span></td>
        </tr>
    </tbody>
</table>
</div>
</div>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<img src ="http://www.cppblog.com/qiaodong/aggbug/25706.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qiaodong/" target="_blank">乔栋</a> 2007-06-07 09:56 <a href="http://www.cppblog.com/qiaodong/archive/2007/06/07/25706.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C 的面试问题</title><link>http://www.cppblog.com/qiaodong/archive/2007/04/05/21294.html</link><dc:creator>乔栋</dc:creator><author>乔栋</author><pubDate>Thu, 05 Apr 2007 03:18:00 GMT</pubDate><guid>http://www.cppblog.com/qiaodong/archive/2007/04/05/21294.html</guid><wfw:comment>http://www.cppblog.com/qiaodong/comments/21294.html</wfw:comment><comments>http://www.cppblog.com/qiaodong/archive/2007/04/05/21294.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qiaodong/comments/commentRss/21294.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qiaodong/services/trackbacks/21294.html</trackback:ping><description><![CDATA[<a href="http://blog.csdn.net/ruibird/archive/2007/03/31/1547882.aspx"><br><br><br><br>http://blog.csdn.net/ruibird/archive/2007/03/31/1547882.aspx</a><br><br><br><br>
<img src ="http://www.cppblog.com/qiaodong/aggbug/21294.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qiaodong/" target="_blank">乔栋</a> 2007-04-05 11:18 <a href="http://www.cppblog.com/qiaodong/archive/2007/04/05/21294.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>宏的使用</title><link>http://www.cppblog.com/qiaodong/archive/2007/04/05/21293.html</link><dc:creator>乔栋</dc:creator><author>乔栋</author><pubDate>Thu, 05 Apr 2007 03:16:00 GMT</pubDate><guid>http://www.cppblog.com/qiaodong/archive/2007/04/05/21293.html</guid><wfw:comment>http://www.cppblog.com/qiaodong/comments/21293.html</wfw:comment><comments>http://www.cppblog.com/qiaodong/archive/2007/04/05/21293.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qiaodong/comments/commentRss/21293.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qiaodong/services/trackbacks/21293.html</trackback:ping><description><![CDATA[<br><br><a href="http://www.vckbase.com/document/viewdoc/?id=957">http://www.vckbase.com/document/viewdoc/?id=957</a><br><br><br><br><br>
<img src ="http://www.cppblog.com/qiaodong/aggbug/21293.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qiaodong/" target="_blank">乔栋</a> 2007-04-05 11:16 <a href="http://www.cppblog.com/qiaodong/archive/2007/04/05/21293.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>斐波那契数列</title><link>http://www.cppblog.com/qiaodong/archive/2007/03/11/19585.html</link><dc:creator>乔栋</dc:creator><author>乔栋</author><pubDate>Sun, 11 Mar 2007 15:02:00 GMT</pubDate><guid>http://www.cppblog.com/qiaodong/archive/2007/03/11/19585.html</guid><wfw:comment>http://www.cppblog.com/qiaodong/comments/19585.html</wfw:comment><comments>http://www.cppblog.com/qiaodong/archive/2007/03/11/19585.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qiaodong/comments/commentRss/19585.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qiaodong/services/trackbacks/19585.html</trackback:ping><description><![CDATA[
		<div style="FONT-SIZE: 12px">main() <br />{<br />        int a,b;<br />        int i; <br />        a=b=1; <br />        for(i=1;i&lt;100;i++) <br />        {<br />                printf("%4d%4d",a,b); <br />                a+=b;<br />                b+=a;<br />        }<br />        printf("\n");<br />}<br /><br /><br /></div>
<img src ="http://www.cppblog.com/qiaodong/aggbug/19585.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qiaodong/" target="_blank">乔栋</a> 2007-03-11 23:02 <a href="http://www.cppblog.com/qiaodong/archive/2007/03/11/19585.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C下使用mysql</title><link>http://www.cppblog.com/qiaodong/archive/2007/03/07/19349.html</link><dc:creator>乔栋</dc:creator><author>乔栋</author><pubDate>Wed, 07 Mar 2007 03:32:00 GMT</pubDate><guid>http://www.cppblog.com/qiaodong/archive/2007/03/07/19349.html</guid><wfw:comment>http://www.cppblog.com/qiaodong/comments/19349.html</wfw:comment><comments>http://www.cppblog.com/qiaodong/archive/2007/03/07/19349.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qiaodong/comments/commentRss/19349.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qiaodong/services/trackbacks/19349.html</trackback:ping><description><![CDATA[Demonstrates   how   to   use   plain   C   to   create   a   MySQL   database,   connect   to   it,   create   a   table   with   fields,   populate   the   table,   execute   an   SQL   query,   and   print   the   results.   No   MFC   required   -   uses   only   plain   C.   <br />    <br />  #include   &lt;conio.h&gt;   <br />  #include   &lt;stdarg.h&gt;   <br />  #include   &lt;stdio.h&gt;   <br />  #include   &lt;stdlib.h&gt;   <br />  #include   "winsock.h"   <br />  #include   "mysql.h"   <br />    <br />  MYSQL           *mysql   =   NULL;   <br />    <br />  void   MySQLError(void)   <br />  {   <br />  fprintf(stderr,   "%s\n",   mysql_error(mysql));   <br />  exit(1);   <br />  }   <br />    <br />  void   ExecuteSQL(char   *fmt,   ...)   <br />  {   <br />  char   SQL[1000]   =   {0};   <br />  int     retval;   <br />  va_list   args;   <br />  va_start(args,   fmt);   <br />  if   (_vsnprintf(SQL,   sizeof(SQL)-1,   fmt,   args)   &lt;   0)   <br />  {   <br />  fprintf(stderr,   "SQL   query   truncated!   Increase   SQL   buffer   size   in   ExecuteSQL\n");   <br />  exit(1);   <br />  }   <br />  va_end(args);   <br />  retval   =   mysql_query(mysql,   SQL);   <br />  if   (retval)   <br />  {   <br />  fprintf(stderr,   "Original   SQL   Statement:   %s\n",   SQL);   <br />  fprintf(stderr,   "%s\n",   mysql_error(mysql));   <br />  exit(2);   <br />  }   <br />  }   <br />    <br />  int   main()   <br />  {   <br />  UINT                   i;   <br />  UINT                   FieldCount;   <br />  MYSQL_RES       *res                   =   NULL;   <br />  MYSQL_ROW         row                   =   NULL;   <br />  MYSQL_FIELD   *field;   <br />    <br />  char             *DBName             =   "Test";   <br />  char             *TableName       =   "People";   <br />  char             *CreateDB         =   "CREATE   DATABASE   IF   NOT   EXISTS   %s";   <br />  char             *DropTable       =   "DROP   TABLE   IF   EXISTS   %s";   <br />  char             *CreateTable   =   "CREATE   TABLE   IF   NOT   EXISTS   %s   (\n"   <br />    "ID                   INT   UNSIGNED   AUTO_INCREMENT,   \n"   <br />    "FirstName     VARCHAR(32),   \n"   <br />    "MiddleName   VARCHAR(32),   \n"   <br />    "LastName       VARCHAR(32),   \n"   <br />    "Address1       VARCHAR(50),   \n"   <br />    "Address2       VARCHAR(50),   \n"   <br />    "City               VARCHAR(50),   \n"   <br />    "State             VARCHAR(2),   \n"   <br />    "Zip                 VARCHAR(5),   \n"   <br />    "Email             VARCHAR(50),   \n"   <br />    "Gender           VARCHAR(1),   \n"   <br />    "WorkPhone     VARCHAR(50),   \n"   <br />    "HomePhone     VARCHAR(50),   \n"   <br />    "CellPhone     VARCHAR(50),   \n"   <br />    "BirthDate     DATE   NULL,   \n"   <br />    "Primary   Key   (ID)   \n"   <br />    ")\n";   <br />  char             *AddRecord       =   "INSERT   INTO   %s   (FirstName,   LastName)   VALUES   ('FirstName   %03d',   'LastName   %03d')";   <br />  char             *GetRecords     =   "SELECT   ID,   FirstName,   LastName   FROM   %s";   <br />    <br />    <br />    <br />  //   Initialize   MySQL   <br />  mysql   =   mysql_init(NULL);   <br />    <br />  //   Connect   to   MySQL   <br />  if   (!(mysql_real_connect(mysql,   "localhost",   "admin",   "",   NULL,   mysql-&gt;port,   0,   0)))     <br />  MySQLError();   <br />    <br />  //   Create   database   <br />  ExecuteSQL(CreateDB,   DBName);   <br />    <br />  //   Connect   to   temporary   database   <br />  if   (mysql_select_db(mysql,   DBName))   <br />  MySQLError();   <br />    <br />  //   Delete   table   if   it   already   exists.   <br />  ExecuteSQL(DropTable,   TableName);   <br />    <br />  //   Create   table   <br />  ExecuteSQL(CreateTable,   TableName);   <br />    <br />  //   Insert   some   data   into   the   table.   <br />  for   (i   =   0;   i   &lt;   200;   i++)   <br />  ExecuteSQL(AddRecord,   TableName,   i,   i);   <br />    <br />  //   Execute   query   <br />  ExecuteSQL(GetRecords,   TableName);   <br />    <br />  //   Store   the   recordset   <br />  if   ((res   =   mysql_store_result(mysql))   ==   NULL)   <br />  MySQLError();   <br />    <br />  //   Print   the   recordset   <br />  printf("Table   %s\n",   TableName);   <br />  while((field   =   mysql_fetch_field(res))   !=   NULL)   <br />  printf("%s\t",   field-&gt;name);   <br />  printf("\n");   <br />  FieldCount   =   mysql_num_fields(res);   <br />  while((row   =   mysql_fetch_row(res))   !=   NULL)     <br />  {   <br />  for   (i   =   0;   i   &lt;   FieldCount;   i++)     <br />  printf("%s\t",   row[i]);   <br />  printf("\n");   <br />  }   <br />  printf("\nTotal   rows:   %d\n",   mysql_num_rows(res));   <br />    <br />  //   Free   the   recordset   <br />  mysql_free_result(res);   <br />    <br />  //   Close   the   connection   <br />  mysql_close(mysql);   <br />    <br />  printf("\nPrint   any   key   to   continue...\n");   <br />  getche();   <br />  }   <br />    <br />  如果有问题，请加入mysql++.lib    <br /><br /><br /><br /><br /><br /><font face="宋体">在VC里的toos-&gt;option-&gt;directories中将include增加一个c:\mysql\include,将lib增加一个c:\mysql\lib,将libmysql.dll和libmysql.lib拷到当前目录下，并且把libmysql.lib增加到工程中。<br />2，      建立与服务器的连接。<br />Include &lt;mysql.h&gt; //包含头文件<br />MYSQL *conn；//定义一个MYSQL类型结构，这个几乎在所有的后面的编程中都需要<br />MYSQL *mysql_init(MYSQL *conn);//如果conn=NULL，返回一个新分配的句柄结构返回，反之则重新初始化该结构，出现错误则返回NULL；<br />MYSQL *mysql_real_connect(MYSQL * connection,const char *server_host,const char *sql_urs_name,const char *sql_password,const char *db_name,unsigned int port_number,const char *unix_socket_name,unsigned int flags);//连接MYSQL服务器，里面的参数应该很清楚了，一般port_number和unix_socket_name的值为0和NULL。例如：<br />mysql_real_connect(conn_ptr,"localhost","sagely","secret","ra",0,NULL,0);<br />     void mysql_close(MYSQL *connection);关闭一个连接。<br />3，      执行SQL语句<br />mysql_select_db（MYSQL *connection,const char *db_name）;选定某个数据库。<br />     int mysql_query(MYSQL *connection,const char *query)//他将执行query语句，运行成功将返回0，例如mysql_query(conn_ptr, Create table cert_info(...),将创建一个名为cert_info的表，几乎所有的SQL语句都能这么执行。呵呵，是不是显得很简单，他就和命令行中输入的SQL语句差不多。在使用上面函数的时候一般会使用<br />     my_ulonglong mysql_affected_rows(MYSQL *connection)，这个函数返回的是mysql_query对进行改动的行的数量。<br />4，      处理检索到的数据<br />当我们可以执行SQL语句以后，那么就很容易执行增加删除修改等操作，但是假若检索出来的数据存储在哪里呢？<br />     MYSQL_RES *mysql_use_result(MYSQL *connection)这个函数得到一个连接对象返回一个结果集合指针，出错时返回NULL。不过他只是返回一个集合对象初始化来接收数据，并没有将任何检索到的数据返回到结果集合中。<br />     MYSQL_ROW mysql_fetch_row(MYSQL_RES *result)这个函数获得mysql_use_resul得到的结果结构体，并从中检索单个行，并返回分配给行结构体的数据，没有更多数据或出错时，返回NULL。<br />     Unsigned int mysql_field_count(MYSQL *connection)它得到一个连接对象并返回在集合中字段的数目。<br />于是有上面的基础我们就可以理解下面这段了：（没有错误处理）<br />mysql_init(&amp;conn_ptr);<br />mysql_real_connect(conn_ptr,"localhost","sagely","secret","ra",0,NULL,0);<br />mysql_query(conn_ptr,"SELECT * form usr_info);<br />res_ptr=mysql_use_result(&amp;conn_ptr);<br />sqlrow=mysql_fetch_row(res_ptr);<br />for(int i=0;i&lt;mysql_field_count(&amp;conn_ptr);i++){printf("%s ",sqlrow);}<br />     MYSQL_FIELD *mysql_fetch_field(MYSQL_RES *result)它返回的是列的信息，比如列的名称，列所在表名称等等，有了这个就可以将列标题与数据想对应起来了。<br /><br /><br /><br /><br /><br /></font><img src ="http://www.cppblog.com/qiaodong/aggbug/19349.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qiaodong/" target="_blank">乔栋</a> 2007-03-07 11:32 <a href="http://www.cppblog.com/qiaodong/archive/2007/03/07/19349.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【 Sizeof  】</title><link>http://www.cppblog.com/qiaodong/archive/2007/03/06/19299.html</link><dc:creator>乔栋</dc:creator><author>乔栋</author><pubDate>Tue, 06 Mar 2007 08:14:00 GMT</pubDate><guid>http://www.cppblog.com/qiaodong/archive/2007/03/06/19299.html</guid><wfw:comment>http://www.cppblog.com/qiaodong/comments/19299.html</wfw:comment><comments>http://www.cppblog.com/qiaodong/archive/2007/03/06/19299.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qiaodong/comments/commentRss/19299.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qiaodong/services/trackbacks/19299.html</trackback:ping><description><![CDATA[
		<table cellspacing="0" cellpadding="0" width="85%" align="center" border="0">
				<tbody>
						<tr>
								<td style="FONT-SIZE: 9pt" align="middle" width="100%" height="20">
										<font color="#666666">
										</font>
								</td>
						</tr>
						<tr>
								<td style="FONT-SIZE: 14px" align="middle" width="100%">
										<table cellspacing="0" cellpadding="0" align="center" border="0">
												<tbody>
														<tr>
																<td height="25">  </td>
														</tr>
														<tr>
																<td style="FONT-SIZE: 14px">本文主要包括二个部分，第一部分重点介绍在VC中，怎么样采用sizeof来求结构的大小，以及容易出现的问题，并给出解决问题的方法，第二部分总结出VC中sizeof的主要用法。<br /><br />1、 sizeof应用在结构上的情况<br /><br />请看下面的结构：<br /><br />struct MyStruct<br /><br />{<br /><br />double dda1;<br /><br />char dda;<br /><br />int type<br /><br />};<br /><br />对结构MyStruct采用sizeof会出现什么结果呢？sizeof(MyStruct)为多少呢？也许你会这样求：<br /><br />sizeof(MyStruct)=sizeof(double)+sizeof(char)+sizeof(int)=13<br /><br />但是当在VC中测试上面结构的大小时，你会发现sizeof(MyStruct)为16。你知道为什么在VC中会得出这样一个结果吗？<br /><br />其实，这是VC对变量存储的一个特殊处理。为了提高CPU的存储速度，VC对一些变量的起始地址做了“对齐”处理。在默认情况下，VC规定各成员变量存放的起始地址相对于结构的起始地址的偏移量必须为该变量的类型所占用的字节数的倍数。下面列出常用类型的对齐方式(vc6.0,32位系统)。<br /><br />类型<br />对齐方式（变量存放的起始地址相对于结构的起始地址的偏移量）<br /><br />Char<br />偏移量必须为sizeof(char)即1的倍数<br /><br />int<br />偏移量必须为sizeof(int)即4的倍数<br /><br />float<br />偏移量必须为sizeof(float)即4的倍数<br /><br />double<br />偏移量必须为sizeof(double)即8的倍数<br /><br />Short<br />偏移量必须为sizeof(short)即2的倍数<br /><br /><br /><br />各成员变量在存放的时候根据在结构中出现的顺序依次申请空间，同时按照上面的对齐方式调整位置，空缺的字节VC会自动填充。同时VC为了确保结构的大小为结构的字节边界数（即该结构中占用最大空间的类型所占用的字节数）的倍数，所以在为最后一个成员变量申请空间后，还会根据需要自动填充空缺的字节。<br /><br />下面用前面的例子来说明VC到底怎么样来存放结构的。<br /><br />struct MyStruct <br /><br />{<br /><br />double dda1; <br /><br />char dda;<br /><br />int type<br /><br />}；<br /><br />为上面的结构分配空间的时候，VC根据成员变量出现的顺序和对齐方式，先为第一个成员dda1分配空间，其起始地址跟结构的起始地址相同（刚好偏移量0刚好为sizeof(double)的倍数），该成员变量占用sizeof(double)=8个字节；接下来为第二个成员dda分配空间，这时下一个可以分配的地址对于结构的起始地址的偏移量为8，是sizeof(char)的倍数，所以把dda存放在偏移量为8的地方满足对齐方式，该成员变量占用sizeof(char)=1个字节；接下来为第三个成员type分配空间，这时下一个可以分配的地址对于结构的起始地址的偏移量为9，不是sizeof(int)=4的倍数，为了满足对齐方式对偏移量的约束问题，VC自动填充3个字节（这三个字节没有放什么东西），这时下一个可以分配的地址对于结构的起始地址的偏移量为12，刚好是sizeof(int)=4的倍数，所以把type存放在偏移量为12的地方，该成员变量占用sizeof(int)=4个字节；这时整个结构的成员变量已经都分配了空间，总的占用的空间大小为：8+1+3+4=16，刚好为结构的字节边界数（即结构中占用最大空间的类型所占用的字节数sizeof(double)=8）的倍数，所以没有空缺的字节需要填充。所以整个结构的大小为：sizeof(MyStruct)=8+1+3+4=16，其中有3个字节是VC自动填充的，没有放任何有意义的东西。<br /><br />下面再举个例子，交换一下上面的MyStruct的成员变量的位置，使它变成下面的情况：<br /><br />struct MyStruct <br /><br />{<br /><br />char dda;<br /><br />double dda1; <br /><br />int type<br /><br />}；<br /><br />这个结构占用的空间为多大呢？在VC6.0环境下，可以得到sizeof(MyStruc)为24。结合上面提到的分配空间的一些原则，分析下VC怎么样为上面的结构分配空间的。（简单说明）<br /><br />struct MyStruct <br /><br />{<br /><br />char dda;//偏移量为0，满足对齐方式，dda占用1个字节；<br /><br />double dda1;//下一个可用的地址的偏移量为1，不是sizeof(double)=8<br /><br />//的倍数，需要补足7个字节才能使偏移量变为8（满足对齐<br /><br />//方式），因此VC自动填充7个字节，dda1存放在偏移量为8<br /><br />//的地址上，它占用8个字节。<br /><br />int type；//下一个可用的地址的偏移量为16，是sizeof(int)=4的倍<br /><br />//数，满足int的对齐方式，所以不需要VC自动填充，type存<br /><br />//放在偏移量为16的地址上，它占用4个字节。<br /><br />}；//所有成员变量都分配了空间，空间总的大小为1+7+8+4=20，不是结构<br /><br />//的节边界数（即结构中占用最大空间的类型所占用的字节数sizeof<br /><br />//(double)=8）的倍数，所以需要填充4个字节，以满足结构的大小为<br /><br />//sizeof(double)=8的倍数。<br /><br /><br /><br />所以该结构总的大小为：sizeof(MyStruc)为1+7+8+4+4=24。其中总的有7+4=11个字节是VC自动填充的，没有放任何有意义的东西。<br /><br /><br /><br />VC对结构的存储的特殊处理确实提高CPU存储变量的速度，但是有时候也带来了一些麻烦，我们也屏蔽掉变量默认的对齐方式，自己可以设定变量的对齐方式。<br /><br />VC中提供了#pragma pack(n)来设定变量以n字节对齐方式。n字节对齐就是说变量存放的起始地址的偏移量有两种情况：第一、如果n大于等于该变量所占用的字节数，那么偏移量必须满足默认的对齐方式，第二、如果n小于该变量的类型所占用的字节数，那么偏移量为n的倍数，不用满足默认的对齐方式。结构的总大小也有个约束条件，分下面两种情况：如果n大于所有成员变量类型所占用的字节数，那么结构的总大小必须为占用空间最大的变量占用的空间数的倍数；<br /><br />否则必须为n的倍数。下面举例说明其用法。<br /><br />#pragma pack(push) //保存对齐状态<br /><br />#pragma pack(4)//设定为4字节对齐<br /><br />struct test<br /><br />{<br /><br />char m1;<br /><br />double m4;<br /><br />int m3;<br /><br />};<br /><br />#pragma pack(pop)//恢复对齐状态<br /><br />以上结构的大小为16，下面分析其存储情况，首先为m1分配空间，其偏移量为0，满足我们自己设定的对齐方式（4字节对齐），m1占用1个字节。接着开始为m4分配空间，这时其偏移量为1，需要补足3个字节，这样使偏移量满足为n=4的倍数（因为sizeof(double)大于n）,m4占用8个字节。接着为m3分配空间，这时其偏移量为12，满足为4的倍数，m3占用4个字节。这时已经为所有成员变量分配了空间，共分配了16个字节，满足为n的倍数。如果把上面的#pragma pack(4)改为#pragma pack(16)，那么我们可以得到结构的大小为24。（请读者自己分析）<br /><br />2、 sizeof用法总结<br /><br />在VC中，sizeof有着许多的用法，而且很容易引起一些错误。下面根据sizeof后面的参数对sizeof的用法做个总结。<br /><br />A． 参数为数据类型或者为一般变量。例如sizeof(int),sizeof(long)等等。这种情况要注意的是不同系统系统或者不同编译器得到的结果可能是不同的。例如int类型在16位系统中占2个字节，在32位系统中占4个字节。<br /><br />B． 参数为数组或指针。下面举例说明.<br /><br />int a[50]; //sizeof(a)=4*50=200; 求数组所占的空间大小<br /><br />int *a=new int[50];// sizeof(a)=4; a为一个指针，sizeof(a)是求指针<br /><br />//的大小,在32位系统中，当然是占4个字节。<br /><br />C． 参数为结构或类。Sizeof应用在类和结构的处理情况是相同的。但有两点需要注意，第一、结构或者类中的静态成员不对结构或者类的大小产生影响，因为静态变量的存储位置与结构或者类的实例地址无关。<br /><br />第二、没有成员变量的结构或类的大小为1，因为必须保证结构或类的每一<br /><br />个实例在内存中都有唯一的地址。<br /><br />下面举例说明，<br /><br />Class Test{int a;static double c};//sizeof(Test)=4.<br /><br />Test *s;//sizeof(s)=4,s为一个指针。<br /><br />Class test1{ };//sizeof(test1)=1;<br /><br />D． 参数为其他。下面举例说明。<br /><br />int func(char s[5]);<br /><br />{<br /><br />cout&lt;<sizeof(s); 这里将输出4，本来s为一个数组，但由于做为函<br=""><br />//数的参数在传递的时候系统处理为一个指针，所<br /><br />//以sizeof(s)实际上为求指针的大小。<br /><br />return 1;<br /><br />}<br /><br />sizeof(func(“1234”))=4//因为func的返回类型为int，所以相当于<br /><br />//求sizeof(int).<br /><br /><br /><br />以上为sizeof的基本用法，在实际的使用中要注意分析VC的分配变量的分配策略，这样的话可以避免一些错误。<br /></sizeof(s);></td>
														</tr>
												</tbody>
										</table>
								</td>
						</tr>
				</tbody>
		</table>
		<br />
		<br />
		<br />
		<br />
		<br />
		<br />
		<br />
		<br />
<img src ="http://www.cppblog.com/qiaodong/aggbug/19299.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qiaodong/" target="_blank">乔栋</a> 2007-03-06 16:14 <a href="http://www.cppblog.com/qiaodong/archive/2007/03/06/19299.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>c/c++ 面试</title><link>http://www.cppblog.com/qiaodong/archive/2007/03/05/19244.html</link><dc:creator>乔栋</dc:creator><author>乔栋</author><pubDate>Mon, 05 Mar 2007 09:13:00 GMT</pubDate><guid>http://www.cppblog.com/qiaodong/archive/2007/03/05/19244.html</guid><wfw:comment>http://www.cppblog.com/qiaodong/comments/19244.html</wfw:comment><comments>http://www.cppblog.com/qiaodong/archive/2007/03/05/19244.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qiaodong/comments/commentRss/19244.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qiaodong/services/trackbacks/19244.html</trackback:ping><description><![CDATA[
		<p>1．实现一个字符串拷贝函数strcpy(char * a, char * b)，b拷贝到a，用C语言实现，要求以性能为首要，请在程序中写上注释。</p>
		<p>2．一个类拷贝的函数，要求用C写<br />例如：<br />class A {<br />int a;<br />public:<br />int b;<br />};</p>
		<p>class B {<br />……<br />……<br />};</p>
		<p>int main() {<br />A aa, bb;<br />B c, d;<br />a.a = 10; a.b = 20;<br />copyclass(???);// 将aa拷贝到bb<br />….<br />copyclass(???);// 将c拷贝到d<br />return 0;<br />}<br />3在一个项目中，你被分配到一个小任务：在一个字符串str中包含字符串str_a，找出所有在字符串str中的str_a，要求你架构这个功能块并且给出使用说明，代码运行健壮并且性能为首要。<br /><br /><br /><br />///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////<br />///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////<br /><br />1、while(*a++=*b++);<br />2、memcpy(&amp;bb, &amp;aa, sizeof(A));<br />memcpy(&amp;d, &amp;c, sizeof(B));<br />3、BOOL FindString(const char *src， const char *str_a)<br />{<br />   char *pStart=(char *)src;<br />   if(NULL==pStart || NULL==str_a) return FALSE;<br />   char *pCursor=pStart;<br />   while(pCursor=strstr(pCursor, str_a))<br />  {<br />     printf("find (%s) at position %ld\r\n"), str_a, pCursor-pStart);   <br />  }<br />  return TRUE;  <br />}</p>
<img src ="http://www.cppblog.com/qiaodong/aggbug/19244.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qiaodong/" target="_blank">乔栋</a> 2007-03-05 17:13 <a href="http://www.cppblog.com/qiaodong/archive/2007/03/05/19244.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>简单匹配算法 </title><link>http://www.cppblog.com/qiaodong/archive/2006/12/25/16831.html</link><dc:creator>乔栋</dc:creator><author>乔栋</author><pubDate>Mon, 25 Dec 2006 05:18:00 GMT</pubDate><guid>http://www.cppblog.com/qiaodong/archive/2006/12/25/16831.html</guid><wfw:comment>http://www.cppblog.com/qiaodong/comments/16831.html</wfw:comment><comments>http://www.cppblog.com/qiaodong/archive/2006/12/25/16831.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qiaodong/comments/commentRss/16831.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qiaodong/services/trackbacks/16831.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt">
				<span lang="EN-US" style="COLOR: #3366ff">
						<font face="Times New Roman">
								<font size="3">int Index_BF ( char S [ ], char T [ ], int pos ) </font>
						</font>
				</span>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="COLOR: #3366ff">
						<font face="Times New Roman">
								<font size="3">{ 
<p></p></font>
						</font>
				</span>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 15.75pt; mso-char-indent-count: 1.5">
				<font size="3">
						<span lang="EN-US">
								<font face="Times New Roman">/* </font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">若串</span>
						<span lang="EN-US">
								<font face="Times New Roman">S </font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">中从第</span>
						<span lang="EN-US">
								<font face="Times New Roman">pos(S </font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">的下标</span>
						<span lang="EN-US">
								<font face="Times New Roman">0</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">≤</span>
						<span lang="EN-US">
								<font face="Times New Roman">pos&lt;StrLength(S))</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">个字符</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 31.5pt; mso-char-indent-count: 3.0">
				<font size="3">
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">起存在和串</span>
						<span lang="EN-US">
								<font face="Times New Roman">T </font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">相同的子串，则称匹配成功，返回第一个</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 31.5pt; mso-char-indent-count: 3.0">
				<font size="3">
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">这样的子串在串</span>
						<span lang="EN-US">
								<font face="Times New Roman">S </font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">中的下标，否则返回</span>
						<span lang="EN-US">
								<font face="Times New Roman">-1<span style="mso-spacerun: yes">    </span>*/</font>
						</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0">
				<span lang="EN-US" style="COLOR: #3366ff">
						<font face="Times New Roman">
								<font size="3">int i = pos, j = 0; 
<p></p></font>
						</font>
				</span>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0">
				<span lang="EN-US" style="COLOR: #3366ff">
						<font face="Times New Roman">
								<font size="3">while ( S[i+j] != '\0'&amp;&amp; T[j] != '\0') 
<p></p></font>
						</font>
				</span>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0">
				<span lang="EN-US" style="COLOR: #3366ff">
						<font face="Times New Roman">
								<font size="3">if ( S[i+j] == T[j] ) 
<p></p></font>
						</font>
				</span>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 36.75pt; mso-char-indent-count: 3.5">
				<font size="3">
						<font face="Times New Roman">
								<span lang="EN-US" style="COLOR: #3366ff">j ++;</span>
								<span lang="EN-US">// </span>
						</font>
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">继续比较后一字符</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0">
				<span lang="EN-US" style="COLOR: #3366ff">
						<font face="Times New Roman">
								<font size="3">else 
<p></p></font>
						</font>
				</span>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 15.75pt; mso-char-indent-count: 1.5">
				<span lang="EN-US" style="COLOR: #3366ff">
						<font face="Times New Roman">
								<font size="3">{ 
<p></p></font>
						</font>
				</span>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 31.5pt; mso-char-indent-count: 3.0">
				<font size="3">
						<font face="Times New Roman">
								<span lang="EN-US" style="COLOR: #3366ff">i ++; j = 0; </span>
								<span lang="EN-US">// </span>
						</font>
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">重新开始新的一轮匹配</span>
						<span lang="EN-US" style="COLOR: #3366ff">
								<p>
								</p>
						</span>
				</font>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 15.75pt; mso-char-indent-count: 1.5">
				<font face="Times New Roman">
						<font size="3">
								<span lang="EN-US" style="COLOR: #3366ff">}</span>
								<span lang="EN-US">
								</span>
						</font>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 10.5pt; mso-char-indent-count: 1.0">
				<span lang="EN-US" style="COLOR: #3366ff">
						<font face="Times New Roman">
								<font size="3">if ( T[j] == '\0') 
<p></p></font>
						</font>
				</span>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 26.25pt; mso-char-indent-count: 2.5">
				<font size="3">
						<font face="Times New Roman">
								<span lang="EN-US" style="COLOR: #3366ff">return i;</span>
								<span lang="EN-US">// </span>
						</font>
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">匹配成功</span>
						<span lang="EN-US">
								<span style="mso-spacerun: yes">
										<font face="Times New Roman">   </font>
								</span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">返回下标</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 10.5pt; mso-char-indent-count: 1.0">
				<span lang="EN-US" style="COLOR: #3366ff">
						<font face="Times New Roman">
								<font size="3">else 
<p></p></font>
						</font>
				</span>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 26.25pt; mso-char-indent-count: 2.5">
				<font size="3">
						<font face="Times New Roman">
								<span lang="EN-US" style="COLOR: #3366ff">return -1; </span>
								<span lang="EN-US">// </span>
						</font>
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">串</span>
						<span lang="EN-US">
								<font face="Times New Roman">S</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">中</span>
						<span lang="EN-US">
								<font face="Times New Roman">(</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">第</span>
						<span lang="EN-US">
								<font face="Times New Roman">pos</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">个字符起</span>
						<span lang="EN-US">
								<font face="Times New Roman">)</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">不存在和串</span>
						<span lang="EN-US">
								<font face="Times New Roman">T</font>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">相同的子串</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font face="Times New Roman">
						<font size="3">
								<span lang="EN-US" style="COLOR: #3366ff">} </span>
								<span lang="EN-US">// Index_BF</span>
								<br />
								<br />
								<br />
								<br />
								<br />
								<br />
								<br />
								<br />
								<br />
						</font>
				</font>
		</p>
<img src ="http://www.cppblog.com/qiaodong/aggbug/16831.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qiaodong/" target="_blank">乔栋</a> 2006-12-25 13:18 <a href="http://www.cppblog.com/qiaodong/archive/2006/12/25/16831.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个Windows API SetROP2(int nDrawMode)的使用</title><link>http://www.cppblog.com/qiaodong/archive/2006/11/20/15465.html</link><dc:creator>乔栋</dc:creator><author>乔栋</author><pubDate>Mon, 20 Nov 2006 09:27:00 GMT</pubDate><guid>http://www.cppblog.com/qiaodong/archive/2006/11/20/15465.html</guid><wfw:comment>http://www.cppblog.com/qiaodong/comments/15465.html</wfw:comment><comments>http://www.cppblog.com/qiaodong/archive/2006/11/20/15465.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qiaodong/comments/commentRss/15465.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qiaodong/services/trackbacks/15465.html</trackback:ping><description><![CDATA[
		<table style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" cellspacing="0" cellpadding="0" width="90%" border="0">
				<tbody>
						<tr>
								<td class="oblog_t_4">
										<span class="style1">
												<font size="3">
												</font>
										</span>
								</td>
						</tr>
						<tr>
								<td>
										<span class="oblog_text">
												<p>偶然发现的一个有用的windows api SetROP2(int nDrawMode)，现在将我对该api的使用的心得归纳如下：</p>
												<p>该函数的主要的作用是根据nDrawMode设置的方式重新设定绘图的方式，下面就不同的nDrawMode值具体解释绘图模式是如何改变的。</p>
												<p>首先就nDrawMode的取值有以下的情况：</p>
												<li>
														<b>R2_BLACK</b>   Pixel is always black.   //所有绘制出来的像素为黑色 
</li>
												<li>
														<b>R2_WHITE</b>   Pixel is always white.    //所有绘制出来的像素为白色 
</li>
												<li>
														<b>R2_NOP</b>   Pixel remains unchanged.   //任何绘制将不改变当前的状态 
</li>
												<li>
														<b>R2_NOT</b>   Pixel is the inverse of the screen color. //当前绘制的像素值设为屏幕像素值的反，这样可以覆盖掉上次的绘图，（自动擦除上次绘制的图形） 
</li>
												<li>
														<b>R2_COPYPEN</b>   Pixel is the pen color.    //使用当前的画笔的颜色 
</li>
												<li>
														<b>R2_NOTCOPYPEN</b>   Pixel is the inverse of the pen color.  //当前画笔的反色 </li>
												<p>/////////////////////////////////////////////////////////////////////////////////example/////////////////////////////////////////////////////////////////////////<br />  ClientDC.SetROP2(R2_NOT);<br />  ClientDC.MoveTo(m_PointOrigin);<br />  ClientDC.LineTo(m_PointOld);<br />  ClientDC.MoveTo(m_PointOrigin);<br />  ClientDC.LineTo(point);<br />  m_PointOld = point;<br />  CView::OnMouseMove(nFlags, point);<br />///////////////////////////////////////////////////////////////////////////////////////end/////////////////////////////////////////////////////////////////////////</p>
												<li>
														<p>总之，上述api的一个作用是在需要改变绘图的模式时，不需要重新设置画笔，只需要设置不同的绘图的模式即可达到相应的目的。</p>
												</li>
												<br />
										</span>
								</td>
						</tr>
				</tbody>
		</table>
<img src ="http://www.cppblog.com/qiaodong/aggbug/15465.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qiaodong/" target="_blank">乔栋</a> 2006-11-20 17:27 <a href="http://www.cppblog.com/qiaodong/archive/2006/11/20/15465.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个关于结构体的问题</title><link>http://www.cppblog.com/qiaodong/archive/2006/11/20/15449.html</link><dc:creator>乔栋</dc:creator><author>乔栋</author><pubDate>Mon, 20 Nov 2006 02:54:00 GMT</pubDate><guid>http://www.cppblog.com/qiaodong/archive/2006/11/20/15449.html</guid><wfw:comment>http://www.cppblog.com/qiaodong/comments/15449.html</wfw:comment><comments>http://www.cppblog.com/qiaodong/archive/2006/11/20/15449.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qiaodong/comments/commentRss/15449.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qiaodong/services/trackbacks/15449.html</trackback:ping><description><![CDATA[
		<p>#include&lt;stdio.h&gt;</p>
		<p>struct a<br />{<br /> int b;<br />};<br />struct b<br />{<br />    int a;<br />};<br />void main()<br />{<br /> a A;<br /> A.b = NULL;<br /> A.b = 1;<br /> <br /> b a;<br /> a.a = 3;<br />}</p>
		<p>在C的环境下，会报错，在C++的情况，这样的操作就是允许的。<br />在C++的编译器中，允许将结构体名作为一个变量名来对待。</p>
<img src ="http://www.cppblog.com/qiaodong/aggbug/15449.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qiaodong/" target="_blank">乔栋</a> 2006-11-20 10:54 <a href="http://www.cppblog.com/qiaodong/archive/2006/11/20/15449.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>你所有用过的 if　语句</title><link>http://www.cppblog.com/qiaodong/archive/2006/11/10/14966.html</link><dc:creator>乔栋</dc:creator><author>乔栋</author><pubDate>Fri, 10 Nov 2006 06:54:00 GMT</pubDate><guid>http://www.cppblog.com/qiaodong/archive/2006/11/10/14966.html</guid><wfw:comment>http://www.cppblog.com/qiaodong/comments/14966.html</wfw:comment><comments>http://www.cppblog.com/qiaodong/archive/2006/11/10/14966.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qiaodong/comments/commentRss/14966.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qiaodong/services/trackbacks/14966.html</trackback:ping><description><![CDATA[
		<div class="altbg2" id="code0" style="CLEAR: both; BORDER-RIGHT: #698cc3 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: #698cc3 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; MARGIN: 3px 2em 2em; BORDER-LEFT: #698cc3 1px solid; WORD-BREAK: break-all; PADDING-TOP: 5px; BORDER-BOTTOM: #698cc3 1px solid">#include &lt;stdio.h&gt;<br />void main()<br />{<br />        int i;<br />        <br />        if(i = -1)<br />                printf("True!\n");<br />        else<br />                printf("False!\n");<br />        <br />        if(i = 0)<br />                printf("True!\n");<br />        else<br />                printf("False!\n");<br />}<br /></div>结果是什么？为什么呢？<img src ="http://www.cppblog.com/qiaodong/aggbug/14966.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qiaodong/" target="_blank">乔栋</a> 2006-11-10 14:54 <a href="http://www.cppblog.com/qiaodong/archive/2006/11/10/14966.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>内存操作 / 野指针</title><link>http://www.cppblog.com/qiaodong/archive/2006/11/09/14905.html</link><dc:creator>乔栋</dc:creator><author>乔栋</author><pubDate>Thu, 09 Nov 2006 07:47:00 GMT</pubDate><guid>http://www.cppblog.com/qiaodong/archive/2006/11/09/14905.html</guid><wfw:comment>http://www.cppblog.com/qiaodong/comments/14905.html</wfw:comment><comments>http://www.cppblog.com/qiaodong/archive/2006/11/09/14905.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qiaodong/comments/commentRss/14905.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qiaodong/services/trackbacks/14905.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 125%">
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">试题</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">4</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">：</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
										<strong>void GetMemory( char *p )</strong>
										<br />
										<strong>{</strong>
										<br />
										<strong>   p = (char *) malloc( 100 );</strong>
										<br />
										<strong>}</strong>
										<br />
										<br />
										<strong>void Test( void ) </strong>
										<br />
										<strong>{</strong>
										<br />
										<strong>   char *str = NULL;</strong>
										<br />
										<br />
										<strong>   GetMemory( str ); </strong>
										<br />
										<strong>   strcpy( str, "hello world" );</strong>
										<br />
										<strong>   printf( str );</strong>
										<br />
										<strong>}</strong>
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">试题</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">5</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">：</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
										<strong>char *GetMemory( void )</strong>
										<br />
										<strong>{   </strong>
										<br />
										<strong>     char p[] = "hello world";       </strong>
										<br />
										<br />
										<strong>     return p;  </strong>
										<br />
										<strong>}</strong>
										<br />
										<strong>void Test( void )</strong>
										<br />
										<strong>{   </strong>
										<br />
										<strong>     char *str = NULL;  </strong>
										<br />
										<br />
										<strong>     str = GetMemory();    </strong>
										<br />
										<strong>     printf( str );    </strong>
										<br />
										<strong>}</strong>
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">试题</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">6</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">：</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<strong>void GetMemory( char **p, int num )</strong>
										<br />
										<strong>{</strong>
										<br />
										<strong>     *p = (char *) malloc( num );</strong>
										<br />
										<strong>}</strong>
										<br />
										<strong>void Test( void )</strong>
										<br />
										<strong>{</strong>
										<br />
										<strong>     char *str = NULL;</strong>
										<br />
										<br />
										<strong>     GetMemory( &amp;str, 100 );</strong>
										<br />
										<strong>     strcpy( str, "hello" ); </strong>
										<br />
										<strong>     printf( str ); </strong>
										<br />
										<strong>}</strong>
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">试题</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">7</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">：</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
										<strong>void Test( void )</strong>
										<br />
										<strong>{</strong>
										<br />
										<strong>     char *str = (char *) malloc( 100 );</strong>
										<br />
										<br />
										<strong>     strcpy( str, "hello" );</strong>
										<br />
										<strong>     free( str ); </strong>
										<br />
										<br />
										<strong>     ...  //</strong>
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">省略的其它语句</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
										<strong>}</strong>
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">解答：</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">试题</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">4</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">传入中</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">GetMemory( char *p )</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">函数的形参为字符串指针，在函数内部修改形参并不能真正的改变传入形参的值，执行完</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
										<strong>char *str = NULL;</strong>
										<br />
										<br />
										<strong>GetMemory( str ); </strong>
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">后的</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">str</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">仍然为</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">NULL</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">；</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">试题</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">5</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
										<strong>     char p[] = "hello world";    </strong>
										<br />
										<br />
										<strong>     return p;  </strong>
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">p[]</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">数组为函数内的局部自动变量，在函数返回后，内存已经被释放。这是许多程序员常犯的错误，其根源在于不理解变量的生存期。</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">试题</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">6</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">GetMemory</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">避免了试题</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">4</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的问题，传入</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">GetMemory</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的参数为字符串指针的指针，但是在</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">GetMemory</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中执行申请内存及赋值语句</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
										<strong>p = (char *) malloc( num );</strong>
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">后未判断内存是否申请成功，应加上：</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
										<strong>if ( p == NULL )</strong>
										<br />
										<strong>{</strong>
										<br />
										<br />
										<strong>   ...//</strong>
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">进行申请内存失败处理</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">　</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">}</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">试题</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">7</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">存在与试题</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">6</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">同样的问题，在执行</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
										<strong>char *str = (char *) malloc(100);</strong>
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">后未进行内存是否申请成功的判断；另外，在</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">free(str)</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">后未置</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">str</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">为空，导致可能变成一个</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">“</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">野</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">”</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">指针，应加上：</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
										<strong>str = NULL;</strong>
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">试题</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">6</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">Test</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">函数中也未对</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">malloc</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的内存进行释放。</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">剖析：</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">试题</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">4</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">～</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">7</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">考查面试者对内存操作的理解程度，基本功扎实的面试者一般都能正确的回答其中</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">50~60</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的错误。但是要完全解答正确，却也绝非易事。</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对内存操作的考查主要集中在：</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">1</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）指针的理解；</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">2</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）变量的生存期及作用范围；</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">3</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）良好的动态内存申请和释放习惯。</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在看看下面的一段程序有什么错误：</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
										<strong>swap( int* p1,int* p2 )</strong>
										<br />
										<strong>{</strong>
										<br />
										<strong>     int *p;</strong>
										<br />
										<br />
										<strong>     *p = *p1;</strong>
										<br />
										<strong>     *p1 = *p2;</strong>
										<br />
										<strong>     *p2 = *p;</strong>
										<br />
										<strong>}</strong>
										<br />
										<br />
								</span>
						</i>
				</b>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">swap</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">函数中，</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">p</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是一个</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">“</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">野</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">”</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">指针，有可能指向系统区，导致程序运行的崩溃。在</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">VC++</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">DEBUG</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行时提示错误</span>
						</i>
				</strong>
				<strong>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">“Access Violation”</span>
						</i>
				</strong>
				<strong>
						<i>
								<span style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。该程序应该改为：</span>
						</i>
				</strong>
				<b>
						<i>
								<span lang="EN-US" style="FONT-SIZE: 13.5pt; LINE-HEIGHT: 125%">
										<br />
										<br />
										<strong>swap( int* p1,int* p2 )</strong>
										<br />
										<strong>{</strong>
										<br />
										<strong>     int p;</strong>
										<br />
										<br />
										<strong>     p = *p1;</strong>
										<br />
										<strong>     *p1 = *p2;</strong>
										<br />
										<strong>     *p2 = p;</strong>
										<br />
										<strong>} </strong>
										<br />
										<br />
										<br />
										<br />
										<br />
										<br />
										<br />
										<br />
										<br />
										<br />
										<br />
										<br />
										<br />
										<br />
										<br style="mso-special-character: line-break" />
										<br style="mso-special-character: line-break" />
								</span>
						</i>
				</b>
		</p>
<img src ="http://www.cppblog.com/qiaodong/aggbug/14905.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qiaodong/" target="_blank">乔栋</a> 2006-11-09 15:47 <a href="http://www.cppblog.com/qiaodong/archive/2006/11/09/14905.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>写一个完美的strcpy / strlen 函数</title><link>http://www.cppblog.com/qiaodong/archive/2006/11/09/14902.html</link><dc:creator>乔栋</dc:creator><author>乔栋</author><pubDate>Thu, 09 Nov 2006 06:48:00 GMT</pubDate><guid>http://www.cppblog.com/qiaodong/archive/2006/11/09/14902.html</guid><wfw:comment>http://www.cppblog.com/qiaodong/comments/14902.html</wfw:comment><comments>http://www.cppblog.com/qiaodong/archive/2006/11/09/14902.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/qiaodong/comments/commentRss/14902.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qiaodong/services/trackbacks/14902.html</trackback:ping><description><![CDATA[
		<p>
				<strong>
						<font color="#808080">试题１：<br /><br />void test1()<br />{<br />   char string[10];<br />   char* str1 = "0123456789";<br /><br />     strcpy( string, str1 );<br />}<br /><br />试题2：<br /><br />void test2()<br />{<br />   char string[10], str1[10];<br />     int i;<br /><br />     for(i=0; i&lt;10; i++)<br />     {<br />        str1</font>
				</strong>
				<i>
						<font color="#808080">
								<strong>= 'a';<br /><br />     }<br /><br />     strcpy( string, str1 );<br />}<br /><br />试题3：<br /><br />void test3(char* str1)<br />{<br />   char string[10];<br /><br />   if( strlen( str1 ) &lt;= 10 )<br />     {<br />            strcpy( string, str1 );<br />     }<br />}<br /><br />解答：<br /><br />试题1字符串str1需要11个字节才能存放下（包括末尾的’\0’），而string只有10个字节的空间，strcpy会导致数组越界；<br /><br />对试题2，如果面试者指出字符数组str1不能在数组内结束可以给3分；如果面试者指出strcpy(string, str1)调用使得从str1内存起复制到string内存起所复制的字节数具有不确定性可以给7分，在此基础上指出库函数strcpy工作方式的给10分；<br /><br />对试题3，if(strlen(str1) &lt;= 10)应改为if(strlen(str1) &lt; 10)，因为strlen的结果未统计’\0’所占用的1个字节。<br /><br />剖析：<br /><br />考查对基本功的掌握：<br /><br />（1）字符串以’\0’结尾；<br /><br />（２）对数组越界把握的敏感度；<br /><br />（３）库函数strcpy的工作方式，如果编写一个标准strcpy函数的总分值为10，下面给出几个不同得分的答案：<br /><br />2分<br /><br />void strcpy( char *strDest, char *strSrc )<br />{<br />　 while( (*strDest++ = * strSrc++) != ‘\0’ );<br />}<br /><br />4分<br />void strcpy( char *strDest, const char *strSrc )<br /><br />//将源字符串加const，表明其为输入参数，加2分<br />{<br />　 while( (*strDest++ = * strSrc++) != ‘\0’ );<br />}<br />7分<br />void strcpy(char *strDest, const char *strSrc)  <br />{<br />//对源地址和目的地址加非0断言，加3分<br />　assert( (strDest != NULL) &amp;&amp; (strSrc != NULL) );<br /><br />　while( (*strDest++ = * strSrc++)  !=  ‘\0’ );<br /><br />}<br />10分<br /><br />//为了实现链式操作，将目的地址返回，加3分！<br />char * strcpy( char *strDest, const char *strSrc )  <br />{<br />　assert( (strDest != NULL) &amp;&amp; (strSrc != NULL) );<br />char *address = strDest;  <br /><br />　while( (*strDest++ = * strSrc++) != ‘\0’ ); <br /><br />  return address;<br />}<br /><br />类似的我们可以写出一个10分的</strong>strlen<strong>函数<br /></strong><font color="#808080">int strlen( const char *str )    //输入参数const<br />{<br />     assert( strt != NULL );    //断言字符串地址非0<br />     int len;<br /><br />     while( (*str++) != '\0' ) <br />     {  <br />            len++; <br />     } <br /><br />     return len;<br /><br />}</font><br /></font>
				</i>
		</p>
<img src ="http://www.cppblog.com/qiaodong/aggbug/14902.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qiaodong/" target="_blank">乔栋</a> 2006-11-09 14:48 <a href="http://www.cppblog.com/qiaodong/archive/2006/11/09/14902.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>给自己指定一项任务</title><link>http://www.cppblog.com/qiaodong/archive/2006/11/09/14891.html</link><dc:creator>乔栋</dc:creator><author>乔栋</author><pubDate>Thu, 09 Nov 2006 01:24:00 GMT</pubDate><guid>http://www.cppblog.com/qiaodong/archive/2006/11/09/14891.html</guid><wfw:comment>http://www.cppblog.com/qiaodong/comments/14891.html</wfw:comment><comments>http://www.cppblog.com/qiaodong/archive/2006/11/09/14891.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qiaodong/comments/commentRss/14891.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qiaodong/services/trackbacks/14891.html</trackback:ping><description><![CDATA[
		<br />
		<br />
		<br />今天，明天，后天，三天时间重新温习一遍侯俊杰的《深入潜出MFC》，系统的回顾一下以前的知识。<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><img src ="http://www.cppblog.com/qiaodong/aggbug/14891.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qiaodong/" target="_blank">乔栋</a> 2006-11-09 09:24 <a href="http://www.cppblog.com/qiaodong/archive/2006/11/09/14891.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在高警戒情况下，大踏步地调试</title><link>http://www.cppblog.com/qiaodong/archive/2006/11/08/14834.html</link><dc:creator>乔栋</dc:creator><author>乔栋</author><pubDate>Wed, 08 Nov 2006 03:06:00 GMT</pubDate><guid>http://www.cppblog.com/qiaodong/archive/2006/11/08/14834.html</guid><wfw:comment>http://www.cppblog.com/qiaodong/comments/14834.html</wfw:comment><comments>http://www.cppblog.com/qiaodong/archive/2006/11/08/14834.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qiaodong/comments/commentRss/14834.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qiaodong/services/trackbacks/14834.html</trackback:ping><description><![CDATA[
		<br />
		<br />
		<br />
		<br />
		<br />一直以为这样的方法比较好？但是今天把MSDN里的一个例子拿出来放在最大警报级别下竟莫名其妙的出现了一个初始化问题？想不通<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><img src ="http://www.cppblog.com/qiaodong/aggbug/14834.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qiaodong/" target="_blank">乔栋</a> 2006-11-08 11:06 <a href="http://www.cppblog.com/qiaodong/archive/2006/11/08/14834.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>