• <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>

            不戒廟

            求助:CString Format自身的溢出的問(wèn)題

            以下是代碼

            1 CString strMsg1 = "確認(rèn)要?jiǎng)h除 %s 嗎?";
            2 CString title = "標(biāo)題";
            3 StrMsg1.Format(strMsg1,title");
            以上這段代碼出錯(cuò)
            Expression:("Buffer too small",0)

            而換成

            1 CString strMsg1 ;
            2 CString title = "標(biāo)題";
            3 StrMsg1.Format("確認(rèn)要?jiǎng)h除 %s 嗎?",title");
            就不出錯(cuò)了

            環(huán)境:Win2k3_En_Sp2 + VS2005

            各位達(dá)人,能告訴我是什么原因。

            posted on 2008-07-19 11:07 不戒大師 閱讀(3744) 評(píng)論(9)  編輯 收藏 引用

            Feedback

            # re: 求助:CString Format自身的溢出的問(wèn)題 2008-07-19 11:35 斯卡

            不明白你的title后為什么要加"  回復(fù)  更多評(píng)論   

            # re: 求助:CString Format自身的溢出的問(wèn)題 2008-07-19 12:06 三不戒大師

            title值是變量啊,并不是固定值
              回復(fù)  更多評(píng)論   

            # re: 求助:CString Format自身的溢出的問(wèn)題[未登錄](méi) 2008-07-19 12:15 Kevin

            title 不是字符串對(duì)象, 而不是char指針, 你應(yīng)該 (LPCSTR)title 才對(duì), 因?yàn)镃String重載了LPCSTR, 這樣在運(yùn)行時(shí)才能自動(dòng)轉(zhuǎn)換成char指針, 匹配到 %s  回復(fù)  更多評(píng)論   

            # re: 求助:CString Format自身的溢出的問(wèn)題[未登錄](méi) 2008-07-19 12:16 Kevin

            改一下"title 不是字符串對(duì)象" 應(yīng)為 "title是CString對(duì)象"  回復(fù)  更多評(píng)論   

            # re: 求助:CString Format自身的溢出的問(wèn)題 2008-07-19 12:40 陳梓瀚(vczh)

            CString能隱式轉(zhuǎn)換到LPCTSTR的,這個(gè)倒不是問(wèn)題。難道CString非空的時(shí)候,F(xiàn)ormat就默認(rèn)『該對(duì)象被重新利用,而不是重新構(gòu)造一個(gè)新的CString對(duì)象』?  回復(fù)  更多評(píng)論   

            # re: 求助:CString Format自身的溢出的問(wèn)題 2008-07-19 12:54 wxyz

            CString::Format
            void Format( LPCTSTR lpszFormat, ... );

            void Format( UINT nFormatID, ... );

            Parameters

            lpszFormat

            A format-control string.

            nFormatID

            The string resource identifier that contains the format-control string.

            Remarks

            Call this member function to write formatted data to a CString in the same way that sprintf formats data into a C-style character array. This function formats and stores a series of characters and values in the CString. Each optional argument (if any) is converted and output according to the corresponding format specification in lpszFormat or from the string resource identified by nFormatID.
            ////!!!!!這地方好像說(shuō)了.
            The call will fail if the string object itself is offered as a parameter to Format. For example, the following code:

            CString str = "Some Data";
            str.Format("%s%d", str, 123); // Attention: str is also used in the parameter list.

            will cause unpredictable results.
            ////!!!!
            When you pass a character string as an optional argument, you must cast it explicitly as LPCTSTR. The format has the same form and function as the format argument for the printf function. (For a description of the format and arguments, seeprintf in the Run-Time Library Reference.) A null character is appended to the end of the characters written.

              回復(fù)  更多評(píng)論   

            # re: 求助:CString Format自身的溢出的問(wèn)題 2008-07-19 16:01 三不戒大師

            @wxyz
            謝謝,終于弄明白是怎么回事了  回復(fù)  更多評(píng)論   

            # re: 求助:CString Format自身的溢出的問(wèn)題 2008-07-19 17:01 陳梓瀚(vczh)

            經(jīng)常看到msdn里面把bug當(dāng)成feature……  回復(fù)  更多評(píng)論   

            # re: 求助:CString Format自身的溢出的問(wèn)題[未登錄](méi) 2008-07-20 08:55 Leo

            @陳梓瀚(vczh)
            這本來(lái)就是一種未定義情況,如同snprintf中將自己作為一個(gè)參數(shù)一樣…  回復(fù)  更多評(píng)論   



            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            My Links

            Blog Stats

            常用鏈接

            留言簿

            隨筆檔案

            搜索

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            久久婷婷五月综合色高清| 久久www免费人成看片| 99久久人人爽亚洲精品美女| 97久久国产综合精品女不卡| 久久久久久精品免费看SSS| 久久影视综合亚洲| 一本大道久久香蕉成人网| 日韩人妻无码一区二区三区久久99| 日韩欧美亚洲国产精品字幕久久久| 国内精品欧美久久精品| 热久久最新网站获取| 亚洲AV无码久久精品成人| 国产精品久久久久久一区二区三区 | 亚洲精品乱码久久久久久蜜桃不卡 | 亚洲国产精品无码久久久不卡| 7777久久久国产精品消防器材| 囯产精品久久久久久久久蜜桃 | 囯产极品美女高潮无套久久久| 性色欲网站人妻丰满中文久久不卡| 亚洲国产精品高清久久久| 久久精品aⅴ无码中文字字幕不卡| 精品久久久久久亚洲| 一本久久精品一区二区| 久久久精品国产免大香伊| 人人狠狠综合久久88成人| 高清免费久久午夜精品| 久久久精品久久久久久| 久久99精品国产麻豆| 久久人妻少妇嫩草AV蜜桃| 2020国产成人久久精品| 久久国产免费观看精品3| 久久影视综合亚洲| 人妻精品久久无码专区精东影业 | 久久综合给合久久国产免费| 久久久久久久尹人综合网亚洲| 免费精品久久天干天干| 三上悠亚久久精品| 一本一本久久a久久精品综合麻豆| 人妻精品久久无码区| 无码人妻少妇久久中文字幕| 91精品国产9l久久久久|