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

            蹣跚前行者

            常用鏈接

            統計

            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++不能運行,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;

            沒有測試出什么時候出錯返回負值呢!!誰給我一個例子?

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

            久久久久久精品成人免费图片| 久久一日本道色综合久久| 久久人人妻人人爽人人爽| 亚洲国产成人精品91久久久 | 久久久久99精品成人片三人毛片 | 国产精品久久久久久久午夜片| 久久精品麻豆日日躁夜夜躁| 久久久无码精品亚洲日韩蜜臀浪潮| 欧美精品丝袜久久久中文字幕| 久久国产三级无码一区二区| 国产国产成人久久精品| 狠狠色丁香婷婷综合久久来| 国产成人久久AV免费| 欧美久久综合性欧美| 精品久久久无码人妻中文字幕豆芽| 久久人爽人人爽人人片AV| 无码国内精品久久人妻| 国产一久久香蕉国产线看观看| 久久久久无码精品国产不卡| 国产成人综合久久综合| 99久久国产热无码精品免费久久久久| 国产精品日韩深夜福利久久| 久久久久亚洲av成人无码电影| 亚洲国产视频久久| 欧美丰满熟妇BBB久久久| 久久综合九色综合97_久久久| 国产亚州精品女人久久久久久 | 久久99热只有频精品8| 久久se精品一区精品二区| 国产精品成人久久久久久久| 久久青青草原精品国产软件| 77777亚洲午夜久久多喷| 久久精品国产亚洲AV无码娇色| 大香网伊人久久综合网2020| 亚洲精品成人久久久| 99麻豆久久久国产精品免费| 久久er国产精品免费观看8| 99久久免费国产精品特黄| 国产高清美女一级a毛片久久w| 97精品依人久久久大香线蕉97| 久久免费精品一区二区|