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

            最新評論

            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ù)值呢!!誰給我一個(gè)例子?

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

            日本精品久久久中文字幕| 久久精品无码一区二区三区日韩| 成人国内精品久久久久影院| 久久久国产一区二区三区| 久久精品不卡| 久久九色综合九色99伊人| 欧美777精品久久久久网| 久久久久婷婷| 久久综合欧美成人| 亚洲欧美国产精品专区久久| 亚洲综合熟女久久久30p| 久久精品亚洲中文字幕无码麻豆| 久久黄视频| 亚洲精品美女久久久久99| 久久精品国产秦先生| 国产精品日韩深夜福利久久| 久久99热这里只有精品国产| 久久久久久久免费视频| 国产三级久久久精品麻豆三级 | 久久超碰97人人做人人爱| 日韩人妻无码精品久久免费一| 亚洲乱码精品久久久久..| 亚洲αv久久久噜噜噜噜噜| 久久99热精品| 久久久久久曰本AV免费免费| 香蕉久久一区二区不卡无毒影院 | 新狼窝色AV性久久久久久| 久久久久久国产精品免费无码| 成人a毛片久久免费播放| 久久久91人妻无码精品蜜桃HD| 无码AV波多野结衣久久| 久久久精品免费国产四虎| 国产精品久久久久久久久软件| 久久综合久久鬼色| 久久精品aⅴ无码中文字字幕不卡 久久精品成人欧美大片 | 亚洲精品乱码久久久久久中文字幕 | 97精品依人久久久大香线蕉97 | 久久亚洲熟女cc98cm| 99久久久精品| 囯产极品美女高潮无套久久久| 99久久免费国产精品热|