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

            liyuxia713

            蹣跚前行者

            常用鏈接

            統(tǒng)計(jì)

            Algorithms

            C++

            最新評(píng)論

            sprintf

            sprintf:  http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/
             

            Portotype:  int printf(char* str, const char* format, parameters);

            Writes into the array pointed by str a C string consisting on a sequence of data formatted as the format argument specifies. After the format parameter, the function expects at least as many additional arguments as specified in format.

            This function behaves exactly as printf does, but writing its result to a string instead of stdout. The size of the array passed as str should be enough to contain the entire formatted string .

            Return value:

            On success, the total number of characters written is returned. This count does not include the additional null-character automatically appended at the end of the string.

            //Success
            //The size of str is long enough
            //the number of additional number match with the format
            const int size = 25;
            char *str = new char[size]; 

               //same as int flag1 = sprintf(str,"%s is written to str.","Test","tEST");
            int flag1 = sprintf(str,"%s is written to str.","Test");
            //Console: 23-Test is written to str
            cout << flag1 << "-" << str << endl; 
            On failure, a negative number is returned.
            //Failure1
            //additional arguments numbers is less than specified is format
            //the second %s transmited as unrecognizable words
            const int size = 25;
            char *str = new char[size]; 
            int flag2 = sprintf(str,"%s %s tttttttttttt","Test");
            //Console: 19--Test @ tttttttttttt
            cout << flag2 << "--" << str << endl;

            //Failure2:the size of str is not long enough
               // 在dev c++不能運(yùn)行,vc6.0沒有問題

            const int size = 25;
            char *str = new char[size]; 
            int flag3 = sprintf(str,"%s jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj","Test");
            //VC6.0 Console: Test jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
            //Dev c++: Console: the same as vc6.0 but throws an cannot read memory exception
            cout << flag3 << "--" << str << endl;

            沒有測試出什么時(shí)候出錯(cuò)返回負(fù)值呢?。≌l給我一個(gè)例子?

            posted on 2010-04-25 19:23 幸運(yùn)草 閱讀(507) 評(píng)論(0)  編輯 收藏 引用 所屬分類: C++

            久久精品一区二区三区AV| 国内精品久久久久久久涩爱 | 久久激情亚洲精品无码?V| 久久99精品久久久久久不卡| 久久影院亚洲一区| 亚洲精品白浆高清久久久久久| 97久久精品无码一区二区| 久久激情五月丁香伊人| 精品久久久久久久无码| 一级A毛片免费观看久久精品| 国产精品美女久久久m| 欧美国产成人久久精品| 精品国产乱码久久久久久浪潮| 亚洲香蕉网久久综合影视| 国产精品一区二区久久精品无码| 中文字幕日本人妻久久久免费| 久久精品二区| 国产精品99久久久久久宅男| 日韩人妻无码精品久久免费一| 欧美激情精品久久久久久| 久久福利青草精品资源站免费| 东方aⅴ免费观看久久av| 欧美午夜A∨大片久久| 亚洲国产成人久久精品动漫| 久久精品人成免费| 国内精品九九久久精品| 亚洲国产成人久久综合一区77| 四虎国产精品免费久久久| 久久精品人成免费| 久久国产精品77777| 亚洲精品无码久久久影院相关影片| 亚洲国产高清精品线久久| 久久亚洲国产精品123区| 久久精品国产99国产精品| 欧美激情精品久久久久久久| 久久丝袜精品中文字幕| 欧美性猛交xxxx免费看久久久| 久久美女网站免费| 久久久噜噜噜久久| 伊人热热久久原色播放www| 久久夜色精品国产噜噜亚洲a|