??xml version="1.0" encoding="utf-8" standalone="yes"?>91久久精品美女,亚洲免费视频网站,亚洲激情图片小说视频http://www.shnenglu.com/huyi/category/997.html&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ------ Keep life simple<br> GMail/GTalk/MSN:huyi.zg@gmail.comzh-cnTue, 20 May 2008 02:27:28 GMTTue, 20 May 2008 02:27:28 GMT60成员函C为std::for_each的第三个参数http://www.shnenglu.com/huyi/archive/2006/12/22/16736.htmlHuYiHuYiFri, 22 Dec 2006 07:10:00 GMThttp://www.shnenglu.com/huyi/archive/2006/12/22/16736.htmlhttp://www.shnenglu.com/huyi/comments/16736.htmlhttp://www.shnenglu.com/huyi/archive/2006/12/22/16736.html#Feedback1http://www.shnenglu.com/huyi/comments/commentRss/16736.htmlhttp://www.shnenglu.com/huyi/services/trackbacks/16736.htmlvoid CBookEditDlg::ForEachBookFunctor(Book book)
{
    ......
}
for_each(books.begin(), books.end(), std::bind1st(mem_fun(&CBookEditDlg::ForEachBookFunctor), this));

关键点在于mem_fun和bind1st的用?br />
for_each的实C最核心的一个调用:functor(*iterater);
׃c非静态成员函敎ͼ必须在实例上调用Q?instance->*pfn)(params);
所以for_each无法直接使用传过ȝ函数地址Q函数指针的W一个参数是cȝ一个实例指针(this指针)Q所以必L办法把这个指针传q去Q用std::bind1stQ?br />
关于mem_fun的一些资料,请参?br />http://www.stlchina.org/documents/EffectiveSTL/files/item_41.html

对于带两个以上参数的成员函数Q用stl是不能达到目的的Q因为mem_fun只能生成不带参数Q或者是仅带一个参数的函数对象Qfunctor)Qbind1st和bind2st也只能对W一个或者是W二个参数进行绑定?br />要实现对L数量参数的成员函数生成functorQ必dstlq行扩展Q所qboost已经做到了这点,boost::bind和boost::mem_fn是更加泛化的std::bind1st和std::mem_func

    void ForEachClassFunctor(Class c, CTreeItem treeItem)
    {
        treeView.InsertItem(c.name.c_str(), treeItem, NULL);
    }

    void ForEachBookFunctor(Book book)
    {
        CTreeItem treeItem = treeView.InsertItem(book.name.c_str(), NULL, NULL);
        vector<Class> v;
        v.push_back(Class(0,0,"nameClass1", "titleClass1"));
        for_each(v.begin(), v.end(),
            boost::bind(boost::mem_fn(&CBookEditDlg::ForEachClassFunctor), this, _1, treeItem));
    }


HuYi 2006-12-22 15:10 发表评论
]]>
UTF-8与Unicode的相互{?/title><link>http://www.shnenglu.com/huyi/archive/2006/12/22/16734.html</link><dc:creator>HuYi</dc:creator><author>HuYi</author><pubDate>Fri, 22 Dec 2006 07:09:00 GMT</pubDate><guid>http://www.shnenglu.com/huyi/archive/2006/12/22/16734.html</guid><wfw:comment>http://www.shnenglu.com/huyi/comments/16734.html</wfw:comment><comments>http://www.shnenglu.com/huyi/archive/2006/12/22/16734.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/huyi/comments/commentRss/16734.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/huyi/services/trackbacks/16734.html</trackback:ping><description><![CDATA[今天用到了Sqlite,׃它内部是使用UTF-8~码Q所以在Windows应用中出Cq?br />单的搜烦了一下,怺转换的方法很多,我觉得比较好的,?br /><a target="_blank">http://www.vckbase.com/document/viewdoc/?id=1444</a><br /><br />我稍微改q了一?<br /><br />    static WCHAR* UTF82Unicode(WCHAR* pBuffer,char *pSource, int buff_size)<br />    {<br />        int i, j, max;<br />        char* uchar = (char *)pBuffer;<br />        max = buff_size - 2;<br />        for(i = 0, j = 0; pSource[j] != '\0'; i += 2, j += 3)<br />        {<br />            if (i > max) {<br />                break;<br />            }<br />            uchar[i+1] = ((pSource[j] & 0x0F) << 4) + ((pSource[j+1] >> 2) & 0x0F);<br />            uchar[i] = ((pSource[j+1] & 0x03) << 6) + (pSource[j+2] & 0x3F);<br />        }<br />        uchar[i] = '\0';<br />        uchar[i+1] = '\0';<br />        return pBuffer;<br />    }<br /><br />在Windows中的话,q有更简单的Ҏ完成转换Q?br />比如从UTF-8到Unicode:<br />    WCHAR buff[255];<br />    <span style="FONT-WEIGHT: bold">MultiByteToWideChar</span>(CP_UTF8, 0, argv[i], -1, buff, sizeof(buff));<br />    item.name = W2A(buff);<br /><br />argv[i]是要转换的字节数l?img src ="http://www.shnenglu.com/huyi/aggbug/16734.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/huyi/" target="_blank">HuYi</a> 2006-12-22 15:09 <a href="http://www.shnenglu.com/huyi/archive/2006/12/22/16734.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Z么要用?(”取代??http://www.shnenglu.com/huyi/archive/2006/10/13/13637.htmlHuYiHuYiFri, 13 Oct 2006 05:50:00 GMThttp://www.shnenglu.com/huyi/archive/2006/10/13/13637.htmlhttp://www.shnenglu.com/huyi/comments/13637.htmlhttp://www.shnenglu.com/huyi/archive/2006/10/13/13637.html#Feedback1http://www.shnenglu.com/huyi/comments/commentRss/13637.htmlhttp://www.shnenglu.com/huyi/services/trackbacks/13637.html在做日志接口的时候,真实的接口函数应该是如下样式的:
__static_logger__.log(int level,const char* fmt, ...);
q里使用了printfcM的技术:可变参数?br />q个技术可以动态的替换字符串fmt中的内容?br />同时Q这个方法可能会被重载,用于不需要可变参数的情况Q?br />__static_logger__.log(int level,const char* fmt);

通常Q我们还会定义一些辅助用的宏Q?br />#define KLOG(X) \
    do { \
        KDBG::printf X; \
    } while (0)

使用的时候,必须按照下面的格式:
KLOG((LM_ERROR, "%s\n", strerror(errno)));
注意Q用了双层的括号?(?br />
Z么不把宏ҎQ?br />#define KLOG(X,Y,...) \
    do { \
        KDBG::log(X,Y,__VA_ARGS__); \
    } while (0)s
从而按如下的“标准Ş式”来使用LOG呢?
KLOG(LM_ERROR, "%s\n", strerror(errno));


{案是宏不能像函数那样重载,KLOG宏只能有一个,是最后定义的那个Q也是能接受的参数个数是固定的?br />



HuYi 2006-10-13 13:50 发表评论
]]>
取自ACE中的bit操作?/title><link>http://www.shnenglu.com/huyi/archive/2006/04/03/4929.html</link><dc:creator>HuYi</dc:creator><author>HuYi</author><pubDate>Mon, 03 Apr 2006 02:08:00 GMT</pubDate><guid>http://www.shnenglu.com/huyi/archive/2006/04/03/4929.html</guid><wfw:comment>http://www.shnenglu.com/huyi/comments/4929.html</wfw:comment><comments>http://www.shnenglu.com/huyi/archive/2006/04/03/4929.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/huyi/comments/commentRss/4929.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/huyi/services/trackbacks/4929.html</trackback:ping><description><![CDATA[ <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #000000"># define ACE_BIT_ENABLED(WORD, BIT) (((WORD) </span> <span style="COLOR: #000000">&</span> <span style="COLOR: #000000"> (BIT)) </span> <span style="COLOR: #000000">!=</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">)<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /># define ACE_BIT_DISABLED(WORD, BIT) (((WORD) </span> <span style="COLOR: #000000">&</span> <span style="COLOR: #000000"> (BIT)) </span> <span style="COLOR: #000000">==</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">)<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /># define ACE_BIT_CMP_MASK(WORD, BIT, MASK) (((WORD) </span> <span style="COLOR: #000000">&</span> <span style="COLOR: #000000"> (BIT)) </span> <span style="COLOR: #000000">==</span> <span style="COLOR: #000000"> MASK)<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /># define ACE_SET_BITS(WORD, BITS) (WORD </span> <span style="COLOR: #000000">|=</span> <span style="COLOR: #000000"> (BITS))<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /># define ACE_CLR_BITS(WORD, BITS) (WORD </span> <span style="COLOR: #000000">&=</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #000000">~</span> <span style="COLOR: #000000">(BITS))</span> </div> <br />附上C中常用的位运用法,取自《C Primer Plus?br /><br />掩码Q即maskQ通常为某一个位?Q而其他位都ؓ0的byteQ如00000100?br /><br />1.把byte中除掩码相同的位外,全部|?Q掩码位不变<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">flags </span><span style="COLOR: #000000">&=</span><span style="COLOR: #000000"> mask</span></div>   10101111 & 00000100 = 00000100<br /><br />2.打开位:打开特定的位Q其他位不变?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">flags </span><span style="COLOR: #000000">|=</span><span style="COLOR: #000000"> MASK</span></div>00001000 | 00000100 = 00001100<br /><br />3.关闭位:关闭特定位,但不影响其他?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">flags </span><span style="COLOR: #000000">&=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">~</span><span style="COLOR: #000000">MASK</span></div>11100101 &=  ~10000000 = 01100101<br /><br />4.转置位:一个位如果打开Q则关闭Q如果关闭,则打开<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">flags </span><span style="COLOR: #000000">^=</span><span style="COLOR: #000000"> MASK</span></div>11100101 ^=  10000000 = 01100101<br />11100101 ^=  00010000 = 11110101<br /><br />5.查看一个位的|<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> ((flag </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000"> MASK) </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> MASK)<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" />    do_some_work();</span></div><br /> <img src ="http://www.shnenglu.com/huyi/aggbug/4929.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/huyi/" target="_blank">HuYi</a> 2006-04-03 10:08 <a href="http://www.shnenglu.com/huyi/archive/2006/04/03/4929.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>l大家共享一个基本算法包http://www.shnenglu.com/huyi/archive/2006/03/23/4479.htmlHuYiHuYiThu, 23 Mar 2006 00:51:00 GMThttp://www.shnenglu.com/huyi/archive/2006/03/23/4479.htmlhttp://www.shnenglu.com/huyi/comments/4479.htmlhttp://www.shnenglu.com/huyi/archive/2006/03/23/4479.html#Feedback0http://www.shnenglu.com/huyi/comments/commentRss/4479.htmlhttp://www.shnenglu.com/huyi/services/trackbacks/4479.html下蝲地址   
http://www.shnenglu.com/Files/huyi/datastruct.rar


包含内容Q?br />下面是文包含的内容:
二分查找1.c
二分查找2.c
二叉?c
其它

单元?br />单@环链?c
单链?c
?c
字符
定长?c

写数字转ؓ大写数字
带头l点双链循环U性表.c
底层~程
效验法
数学问题
数据l构
数组
文gE序
求进?br />汉诺?br />币情况
逆阵
链串.c
链栈.c
N?c
问题法
序?c
序?c
序队列.c

./其它:
c语言H体实例.zip
ȝ递归.c
冒法改q?c
字库DIY-.c
字库DIY.c
白鼠钻q宫.c
扫描?C
挽救软盘.c
汉字字模.c
经元模?c
ID搜烦?c
单数据库.c
~程汉字问题.txt
~随机数.c
试题.C
递堆?C

./单元?
erre2.c
erre.c
数组完全单元.c
栈单元加.c

./字符:
单词倒{.c
反出字符.c
回文.c
字符串查?c
字符~辑.c
字符~辑技?插入和删? .c

./写数字转ؓ大写数字:
写数字转换成大写数?.c
写数字转换成大写数?.c
写数字转换成大写数?.c

./底层~程:
asm.c
C标志W命名源E序.c
ping.c
winsock2.c
旉陷阱.c
出错?c
鼠?c

./效验法:
C.BAT
CMCRC.COM
Crctable.c

./数学问题:
乘法矩阵.c
凉东问题
十五人排?c
叠代整除.c
四分砝码.c
圆周?br />多位阶乘2.c
多位阶乘.c
大加?c
大小倍约.c
大整?c
完数.c
孩分糖?c
明C
qx?c
数学法
桃子猴问?br />灯塔问题.c
NN.c
单计器.c
ҎU纷
递推.c
逻辑Ud.c
阶乘递归.c
阿姆斯特朗数.c
黑白.c

./数学问题/凉东问题:
32.c
re.c
数组递归退?.c
数组递归退?c

./数学问题/圆周?
圆周?c
狐狸圆周?cpp

./数学问题/明C:
明C.c
明C.cpp

./数学问题/数学法:
余u曲线.c
余u直线.c
W号囑Ş.c
l制?c

./数学问题/桃子猴问?
_notes
乘方函数桃子?c
桃子?c
猴子和桃.c
递归桃猴.c
题目.txt

./数学问题/桃子猴问?_notes:

./数学问题/ҎU纷:
ff.c
Ҏ分法.c

./数据l构:
二叉排序?c
二叉树实?c
单链?br />双链表正排序.c
各种排序?c
哈夫曼算?c
哈慢?c
大整?c
建树和遍?c
排序?c
推箱?c
数据l构2.c
数据l构3.c
数据l构.c
无向?c
栈操?c
U性顺序存储结?c
U烦化二叉树.c
q宫.c
q宫问题.c
逆L兰计器.c
递归车厢.c
队列.c

./数据l构/单链?
ww.c
冒排序.c
单链?.c
单链?.c
单链?c
单链表倒序.c
单链表的处理全集.c
建立链表1.c
节点.c
质因?c
链表十五人排?c
链表Q递归Q?c

./数组:
数字Ud.c
数组操作.c
杨辉三角?c
桶排?c
矩阵转换.c
螺旋数组1.c
螺旋数组2.c

./文gE序:
实例1.c
实例2.c
实例3.c
文g加密.c
文g复制.c
文gq接.c
自我复制.c
d文本文g.c
输出自已.c

./求进?
16q制10q制.c
二进制数2.c
二进制数.c

./汉诺?
四塔1.c
四塔2.c
换位递归.c
汉诺?.c
汉诺?c
诺汉塔画囄.c
非递归.c

./币情况:
for循环?c
币分法.c

./逆阵:
单逆阵.c
逆矩?c
逆阵.c

./问题法:
N皇后问题回溯法.c
万年?br />动态计网l最长最短\U?c
矩阵乘法动态规?c
|络最短\径Dijkstra法.c
货郎担分枝限界图形演C?c
货郎担限界算?c
骑士遍历

./问题法/万年?
万年?c
万年历的法 .c

./问题法/骑士遍历:
骑士遍历1.c
骑士遍历2.c
骑士遍历回?c



HuYi 2006-03-23 08:51 发表评论
]]>
如何日文汉字{换成假名昄http://www.shnenglu.com/huyi/archive/2006/03/15/4207.htmlHuYiHuYiWed, 15 Mar 2006 09:58:00 GMThttp://www.shnenglu.com/huyi/archive/2006/03/15/4207.htmlhttp://www.shnenglu.com/huyi/comments/4207.htmlhttp://www.shnenglu.com/huyi/archive/2006/03/15/4207.html#Feedback10http://www.shnenglu.com/huyi/comments/commentRss/4207.htmlhttp://www.shnenglu.com/huyi/services/trackbacks/4207.html其实很简单啦Q不q微软的API应用说明中对q个的描qC不清楚,现将我的实现代码和注意事脓出来l大家参考?/P>
 1#include <INITGUID.H>
 2#include "MSIME.h"
 3.
 4.
 5.
 6    CString sSelect;
 7    this->GetWindowText(sSelect);
 8
 9    IFELanguage *lang = NULL;
10    if(SUCCEEDED(CoCreateInstance(CLSID_MSIME_JAPANESE_6,NULL,
11        CLSCTX_INPROC_SERVER,IID_IFELanguage,(void**)&lang)) && lang != NULL)
12    {
13        if(!SUCCEEDED(lang->Open()))
14        {
15            return;
16        }

17    }

18    if(lang)
19    {
20        CString sResult;
21        BSTR out = NULL;
22        if(SUCCEEDED(lang->GetPhonetic(_bstr_t(sSelect),1,-1,&out)) && out != NULL)
23        {
24            sResult = out;
25            ::SysFreeString(out);
26        }

27        this->SetWindowText(sResult);
28    }
W?行的include比较重要Q如果不加,Ҏ出现链接错误Q这是在platform的SDK中带有的头文件?BR>W?行是关键性头文gQ在微Yjapan ime文的append部分带有Q现在最新是1.3版?BR>其他部分照猫画虎p了,值得注意的是CLSID_MSIME_JAPANESE_6q个Q如果要惛_win2000下用Q一定要用低版本的,推荐像我q样??BR>
用这套APIQ还可以完成cM于{换拼音之cȝ功能Q如果要创造自q输入法,看看TSFQ微软给了很多TSF的例子?BR>

HuYi 2006-03-15 17:58 发表评论
]]>
链接COME序时容易出现的一个错?/title><link>http://www.shnenglu.com/huyi/archive/2006/03/12/4044.html</link><dc:creator>HuYi</dc:creator><author>HuYi</author><pubDate>Sun, 12 Mar 2006 04:32:00 GMT</pubDate><guid>http://www.shnenglu.com/huyi/archive/2006/03/12/4044.html</guid><wfw:comment>http://www.shnenglu.com/huyi/comments/4044.html</wfw:comment><comments>http://www.shnenglu.com/huyi/archive/2006/03/12/4044.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/huyi/comments/commentRss/4044.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/huyi/services/trackbacks/4044.html</trackback:ping><description><![CDATA[<P>我在链接一个程序时出现的错误信息:<BR>A Note error LNK2001: unresolved external symbol _IID_XXXXXX<BR><BR>加上如下行后链接成功。s</P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">#include </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">INITGUID.H</SPAN><SPAN style="COLOR: #000000">></SPAN></DIV><img src ="http://www.shnenglu.com/huyi/aggbug/4044.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/huyi/" target="_blank">HuYi</a> 2006-03-12 12:32 <a href="http://www.shnenglu.com/huyi/archive/2006/03/12/4044.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>l构体最后的长度?或?的数l?/title><link>http://www.shnenglu.com/huyi/archive/2006/03/07/3837.html</link><dc:creator>HuYi</dc:creator><author>HuYi</author><pubDate>Tue, 07 Mar 2006 04:23:00 GMT</pubDate><guid>http://www.shnenglu.com/huyi/archive/2006/03/07/3837.html</guid><wfw:comment>http://www.shnenglu.com/huyi/comments/3837.html</wfw:comment><comments>http://www.shnenglu.com/huyi/archive/2006/03/07/3837.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.shnenglu.com/huyi/comments/commentRss/3837.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/huyi/services/trackbacks/3837.html</trackback:ping><description><![CDATA[     摘要: 在Linuxpȝ里,/usr/include/linux/if_pppox.h里面有这样一个结构: 1struct pppoe_tag {2    __u16 tag_type;3    __u16 tag_len;4    char&n...  <a href='http://www.shnenglu.com/huyi/archive/2006/03/07/3837.html'>阅读全文</a><img src ="http://www.shnenglu.com/huyi/aggbug/3837.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/huyi/" target="_blank">HuYi</a> 2006-03-07 12:23 <a href="http://www.shnenglu.com/huyi/archive/2006/03/07/3837.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>大写字符串快速{换成写的函?/title><link>http://www.shnenglu.com/huyi/archive/2006/03/03/3678.html</link><dc:creator>HuYi</dc:creator><author>HuYi</author><pubDate>Fri, 03 Mar 2006 05:01:00 GMT</pubDate><guid>http://www.shnenglu.com/huyi/archive/2006/03/03/3678.html</guid><wfw:comment>http://www.shnenglu.com/huyi/comments/3678.html</wfw:comment><comments>http://www.shnenglu.com/huyi/archive/2006/03/03/3678.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/huyi/comments/commentRss/3678.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/huyi/services/trackbacks/3678.html</trackback:ping><description><![CDATA[<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080"> 1</SPAN><IMG id=Codehighlighter1_0_39_Open_Image onclick="this.style.display='none'; Codehighlighter1_0_39_Open_Text.style.display='none'; Codehighlighter1_0_39_Closed_Image.style.display='inline'; Codehighlighter1_0_39_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_0_39_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_0_39_Closed_Text.style.display='none'; Codehighlighter1_0_39_Open_Image.style.display='inline'; Codehighlighter1_0_39_Open_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN id=Codehighlighter1_0_39_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN><SPAN id=Codehighlighter1_0_39_Open_Text><SPAN style="COLOR: #008000">/*</SPAN><SPAN style="COLOR: #008000"> 32-bit, little-endian. suif.liyuan </SPAN><SPAN style="COLOR: #008000">*/</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"> 2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080"> 3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> zbyter(unsigned </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> x)<BR></SPAN><SPAN style="COLOR: #008080"> 4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080"> 5</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_70_328_Open_Image onclick="this.style.display='none'; Codehighlighter1_70_328_Open_Text.style.display='none'; Codehighlighter1_70_328_Closed_Image.style.display='inline'; Codehighlighter1_70_328_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_70_328_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_70_328_Closed_Text.style.display='none'; Codehighlighter1_70_328_Open_Image.style.display='inline'; Codehighlighter1_70_328_Open_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_70_328_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_70_328_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080"> 6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080"> 7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>     unsigned </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> y;<BR></SPAN><SPAN style="COLOR: #008080"> 8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080"> 9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>     y </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> (x </SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0x7F7F7F7F</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0x7F7F7F7F</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>     y </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">~</SPAN><SPAN style="COLOR: #000000">(y </SPAN><SPAN style="COLOR: #000000">|</SPAN><SPAN style="COLOR: #000000"> x </SPAN><SPAN style="COLOR: #000000">|</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0x7F7F7F7F</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>     </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000"> (y </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">)<BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>          </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">4</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>     </SPAN><SPAN style="COLOR: #0000ff">else</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000"> (y </SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0x0000FFFF</SPAN><SPAN style="COLOR: #000000">)<BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>          </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> ((y </SPAN><SPAN style="COLOR: #000000">>></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">7</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN style="COLOR: #000000">^</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>     </SPAN><SPAN style="COLOR: #0000ff">else</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>          </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> ((y </SPAN><SPAN style="COLOR: #000000">>></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">23</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN style="COLOR: #000000">^</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">3</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">25</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">26</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">27</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> UptoLow(</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000"> pszString)<BR></SPAN><SPAN style="COLOR: #008080">28</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">29</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_362_710_Open_Image onclick="this.style.display='none'; Codehighlighter1_362_710_Open_Text.style.display='none'; Codehighlighter1_362_710_Closed_Image.style.display='inline'; Codehighlighter1_362_710_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_362_710_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_362_710_Closed_Text.style.display='none'; Codehighlighter1_362_710_Open_Image.style.display='inline'; Codehighlighter1_362_710_Open_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_362_710_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_362_710_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">30</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">31</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>     </SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000"> pByte </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">32</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">33</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>     </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000"> pn4byte </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">34</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">35</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>     </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> zPos;<BR></SPAN><SPAN style="COLOR: #008080">36</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">37</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>     pn4byte </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> (</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">)pszString;<BR></SPAN><SPAN style="COLOR: #008080">38</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">39</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>     </SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000"> (</SPAN><SPAN style="COLOR: #0000ff">true</SPAN><SPAN style="COLOR: #000000">)<BR></SPAN><SPAN style="COLOR: #008080">40</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">41</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_485_596_Open_Image onclick="this.style.display='none'; Codehighlighter1_485_596_Open_Text.style.display='none'; Codehighlighter1_485_596_Closed_Image.style.display='inline'; Codehighlighter1_485_596_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_485_596_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_485_596_Closed_Text.style.display='none'; Codehighlighter1_485_596_Open_Image.style.display='inline'; Codehighlighter1_485_596_Open_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>     </SPAN><SPAN id=Codehighlighter1_485_596_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_485_596_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">42</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">43</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>         zPos </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> zbyter(</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">pn4byte);<BR></SPAN><SPAN style="COLOR: #008080">44</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">45</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>         </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000"> (</SPAN><SPAN style="COLOR: #000000">4</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000"> zPos) </SPAN><SPAN style="COLOR: #0000ff">break</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">46</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">47</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>         </SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">pn4byte</SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">|=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0x20202020</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">48</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">49</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>     }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">50</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">51</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>     pByte </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> (</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">)pn4byte;<BR></SPAN><SPAN style="COLOR: #008080">52</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">53</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>     </SPAN><SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #000000"> (</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> i </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">; i </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000"> zPos; </SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">i)<BR></SPAN><SPAN style="COLOR: #008080">54</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">55</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>         </SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">pByte</SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">|=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0x20</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">56</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">57</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>     </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">58</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">59</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"> </SPAN></DIV>g很高效的样子:)<img src ="http://www.shnenglu.com/huyi/aggbug/3678.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/huyi/" target="_blank">HuYi</a> 2006-03-03 13:01 <a href="http://www.shnenglu.com/huyi/archive/2006/03/03/3678.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>STL中string的初始化问题http://www.shnenglu.com/huyi/archive/2006/03/03/3674.htmlHuYiHuYiFri, 03 Mar 2006 03:20:00 GMThttp://www.shnenglu.com/huyi/archive/2006/03/03/3674.htmlhttp://www.shnenglu.com/huyi/comments/3674.htmlhttp://www.shnenglu.com/huyi/archive/2006/03/03/3674.html#Feedback0http://www.shnenglu.com/huyi/comments/commentRss/3674.htmlhttp://www.shnenglu.com/huyi/services/trackbacks/3674.html在邮件列表中有朋友提出:

1//我希望把string赋?0Q然后显C?/SPAN>
2string Buffer;
3sprintf( Buffer.begin(),"%d",10);
4MessageBox(NULL,Buffer.begin(),NULL,MB_OK);

ZE序Q编译它Q是通不q的。原因是Buffer没有初?WBR>Q调用Buffer.begin()q回是NULLQ第三句用MessageBox弹出一个NULL的字W串Q这是不可取的?BR>
1//Ҏ后的E序
2string Buffer = "a"//我随便给了个初?/SPAN>
3sprintf( Buffer.begin(),"%d",10);
4MessageBox(NULL,Buffer.begin(),NULL,MB_OK);

但是Q上面这D늨序,可读性能差。别Z惻I作者ؓ什么给?a"而不?b"呢?

所以我惌教大Ӟ
Q?Q这问题有没有更好的ҎQ最好不要MFCQ也不用char?WBR>l,因ؓ整个E序中其它地Ҏ都用了string?BR>Q?QSTLZ么这么设计?
N定义Buffer以后Q还没有分配I间Q如果已l有I间Qؓ什么不用Begin()q回首个字符的地址Q这样做意义呵在Q?BR>


解答一Q?/P>

1// q么定义Q?/SPAN>
2string Buffer(256'\0');
3// 或?/SPAN>
4string Buffer;
5Buffer.reserve(256);

解答二:
1// 1.使用boost:Buffer = boost::lexical_cast<string>(10);
2// 2.如果不想用boostQ?/SPAN>
3#include <sstream>
4
5std::stringstream sstr;
6sstr << 10;
7Buffer = sstr.str();
8// 或者:
9Buffer = (std::stringstream() << 10).str(); 

解答三:
 1  std::vector<char> buf(buffer_size, 0);
 2  _snprintf(&buf[0], buffer_size, "%d\0"10);
 3  // 赋值给字符?/SPAN>
 4  std::string str = &buf[0];
 5  MessageBox(NULL, str.c_str(), NULL, MB_OK);
 6//好处Q?BR> 7//    1. 使用std::vector避免手动new/delete
 8//    2. 使用stl可以充分利用stl的allocQ如stlport的memory pool)
 9//    3. 使用_snprintf防止溢出
10//    4. std::string = std::vectorQ安?Q?/SPAN>

解答四:
1  char buf[32];
2  _snprintf(buf, 32"%d"10);//或者用itoa(10, buf, 10);
3  string str = buf;

有朋友发C个错误:
看到一个明N误的做法Q?/FONT>str.reserve(NLEN)之后直接?/SPAN>sprintf。要知道reserve只是?/SPAN>capacity扩充?/SPAN>NLENQƈ不会扩充size。对于某些标准库实现Q这L做法极端危险Q它会破?/SPAN>string的不变式Q导致一pd严重问题Q比?/SPAN>str.size()?/SPAN>str.length()得到错误的倹{?BR>
oscar.ken@gmail.comQ?BR>
 1#ifdef  UNICODE
 2
 3# define tchar wchar_t
 4# define tstring std::wstring
 5
 6#else
 7
 8# define tchar char
 9# define tstring std::string
10
11#endif
12inline tstring FormatString(const tchar* fmt, )
13{
14 static tchar tmp[2048];
15 memset(tmp, 02048 * sizeof(tchar));
16 va_list args;
17 va_start(args, fmt);
18 int re = _vsntprintf(tmp, 2048, fmt, args);
19 va_end(args);
20 return tstring(tmp);
21}

22
23// 如果2048不够用,可以攚w一个template版本

千里马肝Q?BR>
如果q样
那不如直接用boost::format导出一个stream的stringQ更安逸(当然会慢一些)
 
PSQ对于FormatStringZ保证format出来的是一个stringQ每ơmemsetQ个为无大必要,不如自动在formatstring的最后每ơ自动加上\
0  (XD)

如果我没有记错的?BR>_snprintf是不会自动补\0?BR>而sprintf?BR>所以要么char buf[32= {0}Q要么_snprintf( "%d\0")
另外vector的用是Z配合“不定长buf”而存在,qbuf[
32]的替代品

Jiong TuQ?BR>
你搞错了,不补0的是strncpy,不是snprintf

吴咏炜:
?nbsp;STL 的最大好处就是空间大可以自动增长,不会发生~冲区溢出(安全?BR>题)。否则,又何必付出缓慢的堆上分配的代价呢Q——除非要把结果传回去Q那q?BR>有意义;但最初苏益坾提出的问题中q不存在q样的需求?BR>
另外Z提一下,如果栈上分配内存大小不固定,也不一定就要改用堆上分配?BR>C99 支持数组大小q行时决定(而非 C89
/C++98 的编译时军_Q,而(不支?BR>C99 的)大部?nbsp;C/C++ ~译器也都支持一个非标准?nbsp;alloca 函数用于q行栈上
分配。这个函数通常q译器内联实现Q需要效率的场合会用得上?BR>
另外Q你出?nbsp;
50% 应当是M的性能下降。纯_的内存分配/释放操作Q堆上分
配和栈上分配的性能Ҏ不在同一个量U,差距通常在十倍以上?/SPAN>


HuYi 2006-03-03 11:20 发表评论
]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            Ʒҹ߹ۿ| þþþþþþþþһ | һܻе˾| Ůջվһ| 91þþƷþùɫҲ91 | 99Ƶ߾ƷԲѹۿ| ˾ƷƵһ| þüۺϾƷ| ߳СƵ| ŷ龫Ʒþþþþô߶ | һһþaþþƷۺ鶹| ŷ| ŷ߹ۿ| þþþþþۺɫһ| ˳7777| ŷӰ߹ۿ| ܻƺܻƼ| ޾Ʒһ߹ۿ| ŷպһ| þþ˳ӰƬһ | þþƷһѿ| ޵һƷ| 99Ƶ߹ۿһ| ŷպ| ޹ھƷ| ŷ͵| ձƵһ| ŷҹƷþþþþþ| þĻһ| ŷһƵ߹ۿ| ŷһŷһ߲| ޾ƷӰ| þü¶| Ƶ| ŷպ| þŷһ| ŷպһ| ޸߹ۿ| һƷ߹ۿ| 99߾Ʒۿ| ޹| þþƷһ| һ߿| Ұŷһ| þѾƷƵ| Ʒһü٤| ޹һ| Ʒѹۿ| ŷһ߹ۿ| רһ| ŷպ| ޼| Ƶ߹ۿ| þ͵wcŮ͵| þþƷþ˼˼| Ʒþþþþþҹ| 9lƷþþþ鶹| պվ߹ۿ| ŷӰƨsp| 91þ߿ڹ۲ݲ| ޹ƷþþþþŮ| þó˹| ѳwww| ѹۿһ| þþþþѨ| ŷƵ߹ۿ| ޹ƷԲavϼ| þþþùƷ| 91| Ʒ91Ƶ| ݺݺݾƷƵ| vavaŷva| һ߹ۿƵ| ŷaһƵ| ŷ龫Ʒþþþþӡ| պƵ| Ůͬһһ| ޸Ƶ| һŷ| ƷƵһ| þþƷž| ޴Ƭav| һ| ŷպ| þþþŷƷ| ޼ŷ| ŷպƷþþ| պŷ| Ůþվ| һ| þþþþþۺɫһ| ޵һƷӰ| ŷպƵҳ| ҹƷþ99ҵĹܽ| þۺϸ| һɫ| ھƷþþþþӰ8| þһ| ŷ| һƷŷպһ| ֻоƷƵ| þavԴվ| Ƶ| ƷŮþþþa| ǾþõƵ| ޻ɫӰƬ| þþƷȾþ| ³| ھþþƷ| Ʒþþþþavغ| þwww˳ɿƬ| ޾Ʒѿ| | þó97Ļ| 99ֻоƷ8| ѾƷƵ| ŷͽһƷ| þþۺϾƷ| һ߹ۿ| ޸Ʒ| ŷhƵ| þþþþҹƷƷ| av| һɫþۺϺݺƪŵ| һպ| ƷŮһ| ŷ龫Ʒþþþþô߶| þþƷˬ| ŷһ߹ۿַ| Ů߹ۿ| 91þþƷ91ɫ| ŷһƵ | ŷһ| Ʒһ| žžþùƷص| Ʒ| ƷˬҵĿɰ | պþ| Ϸһ| Ʒþþþþavغ| ŷպ| ŷպһ߹ۿ | þһ| þþþþ91 | ŷƵһ| ˮƵһ| һŷƬ߹ۿ| Ѹһ| ŷҹ| ŷƷƷ| ŷպƷ| Ʒ˰| ƷƵ߹ۿ| ƷһŮڵ| ŷձٸ99| ƷþþþþëƬ | þþۺվ| ŷaaaa| Ʒþһ| ŷƵ| Ƶ| ѵӰ߹ۿ| һƵ߹ۿ | ޸Ƶһ| ޾þƵ| ŷһ| þþ99Ƶ| ŷƷպһ| Ʒպһ| ƷӰ| Ƶ߹ۿƵ| þùۺϾƷ| ޸߹ۿһ| Ƶ| þŷһ| ŷպ| ҹƷȫƵ| ޹ŷһþ| һ| ŷ88av| ŷպ| ŷ3ҳ| ۺվ| ҹӰ߹ۿ| þþƷ99| ŷƵ| þþƷ޸| ŷ޼| Ʒһ| ҹƷһ| 鶹þ| ŷպ| ŷպСƵ| ŷһ| ŷպר| ޸弤| þ| ĹھƷþ| ŷƷһ| ձһ|