• <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 幸運草 閱讀(494) 評論(0)  編輯 收藏 引用 所屬分類: C++

            综合久久国产九一剧情麻豆 | MM131亚洲国产美女久久| 99久久综合国产精品免费| 777午夜精品久久av蜜臀| 久久免费小视频| 人妻无码αv中文字幕久久琪琪布 人妻无码精品久久亚瑟影视 | 一本色道久久综合亚洲精品| 久久久久久久亚洲Av无码| 国产免费久久久久久无码| 久久精品国产99久久久古代| 国产成人精品久久亚洲高清不卡| 久久大香萑太香蕉av| 99热精品久久只有精品| 久久久久精品国产亚洲AV无码| 国产激情久久久久影院老熟女免费 | 久久久精品视频免费观看| 欧美一区二区三区久久综合| 久久毛片免费看一区二区三区| 久久影院综合精品| 久久九九久精品国产免费直播| 国产精品久久久久久久午夜片 | 久久国产亚洲精品| 狠狠色综合网站久久久久久久| 国产精品青草久久久久婷婷 | 欧美久久一级内射wwwwww.| 1000部精品久久久久久久久| 精品多毛少妇人妻AV免费久久 | 婷婷久久综合九色综合九七| 中文字幕久久欲求不满| 97久久超碰国产精品2021| 久久精品国产99久久无毒不卡| 99久久99久久精品国产片果冻 | 久久久久久精品久久久久| 亚洲国产成人精品91久久久| 久久人人爽人人爽人人片AV麻豆 | 久久婷婷国产综合精品| 亚洲国产精品无码久久久蜜芽| 午夜天堂av天堂久久久| 久久亚洲精品无码AV红樱桃| 久久久久亚洲av无码专区导航| 国产精品一久久香蕉产线看|