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

            久久国产综合精品五月天| 久久久久久久97| 久久精品成人| 国内精品久久久久影院老司| 久久永久免费人妻精品下载| 国产精品一区二区久久| 国内精品伊人久久久久妇| 久久美女网站免费| 中文字幕人妻色偷偷久久| 7国产欧美日韩综合天堂中文久久久久 | 久久精品国产一区| 精品伊人久久大线蕉色首页| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 久久精品国产亚洲αv忘忧草| 97久久香蕉国产线看观看| 精品久久久久久久久免费影院 | 国产精品久久久亚洲| 中文字幕精品无码久久久久久3D日动漫 | 国内精品久久久久久久久电影网| 亚洲午夜久久久久久久久电影网| 久久精品二区| 国产2021久久精品| 麻豆精品久久精品色综合| 久久国产精品99国产精| 偷窥少妇久久久久久久久| 欧美性大战久久久久久| 久久亚洲天堂| 婷婷国产天堂久久综合五月| 久久精品国产清自在天天线| 99久久夜色精品国产网站| 岛国搬运www久久| segui久久国产精品| 久久精品国产精品亚洲下载| 久久亚洲国产精品五月天婷| 欧美日韩精品久久久免费观看 | 久久精品aⅴ无码中文字字幕重口| 久久人妻AV中文字幕| 久久国产精品99精品国产| 久久最新精品国产| 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 国产V综合V亚洲欧美久久|