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

            久久久久久亚洲精品无码| 亚洲中文字幕久久精品无码APP| 久久久一本精品99久久精品66| 国内精品伊人久久久久777| 久久精品国产AV一区二区三区 | 国产亚洲色婷婷久久99精品91| 国产产无码乱码精品久久鸭| 国产午夜精品久久久久九九电影| 欧美亚洲另类久久综合婷婷| 亚洲精品无码专区久久久| 久久精品国产亚洲沈樵| 久久婷婷五月综合成人D啪| 久久综合给合久久国产免费| 久久99热这里只有精品国产| 亚洲人成伊人成综合网久久久| 一本大道久久a久久精品综合| 久久久久久精品久久久久| 久久亚洲欧美日本精品| 亚洲精品无码久久久久sm| 久久九色综合九色99伊人| 久久亚洲AV成人无码电影| 久久综合久久鬼色| 99久久国产免费福利| 热re99久久精品国99热| 久久伊人五月丁香狠狠色| 国产亚州精品女人久久久久久 | 久久久久亚洲AV片无码下载蜜桃| 国产精品日韩深夜福利久久| 亚洲va国产va天堂va久久| 久久精品中文字幕一区| 精品久久久久久无码国产| 天天爽天天爽天天片a久久网| 久久久久久久亚洲Av无码| 久久精品国产99国产精品亚洲| 久久久久亚洲AV综合波多野结衣 | 无码超乳爆乳中文字幕久久 | 青青青国产成人久久111网站| 无码国内精品久久人妻| 欧美噜噜久久久XXX| 久久精品国产亚洲AV麻豆网站| 亚洲精品乱码久久久久久|