• <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品| 久久丝袜精品中文字幕| 色妞色综合久久夜夜| 一本色综合网久久| 2022年国产精品久久久久| 久久精品国产黑森林| 亚洲人成无码久久电影网站| 69久久夜色精品国产69| 国产巨作麻豆欧美亚洲综合久久| 欧美久久天天综合香蕉伊| 国产综合久久久久| 狠狠色婷婷久久一区二区| 无码人妻少妇久久中文字幕蜜桃| 久久久中文字幕日本| 亚洲精品乱码久久久久66| 国产成人香蕉久久久久 | 久久99精品久久久久婷婷| 精品水蜜桃久久久久久久| 久久ZYZ资源站无码中文动漫| 亚洲国产精品成人久久蜜臀| 久久国产乱子伦免费精品| 久久久久久午夜精品| 欧美精品丝袜久久久中文字幕 | 久久精品国产69国产精品亚洲 | 久久人人爽人人澡人人高潮AV| 久久久久人妻一区二区三区| 亚洲国产婷婷香蕉久久久久久 | 久久黄视频| 99久久99久久久精品齐齐| 久久精品卫校国产小美女| 久久亚洲2019中文字幕| 99久久国产免费福利| 久久国产精品波多野结衣AV| 97久久国产亚洲精品超碰热| 东方aⅴ免费观看久久av| 亚洲精品无码久久毛片| 午夜视频久久久久一区| 欧美亚洲日本久久精品| 久久久久久久91精品免费观看| 久久亚洲国产成人影院| 久久99精品久久久大学生|