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

            HUUYUU

            c++中的string用法(一)

            ?

            basic_string::append

            string 的后面加字符或字符串。(+=, push_back 更靈活)

            (1) string 的后面加C-string

            basic _ string& append( const value _ type* _Ptr );

            string s ( "Hello " ); // s= Hello

            const char *c = "Out There ";

            s.append ( c ); // s= Hello Out There

            (2) string 的后面加C-string 的一部分

            basic _ string& append( const value _ type* _Ptr , size _ type _Count );

            string s ( "Hello " ); // s= Hello

            const char *c = "Out There ";

            s.append ( c , 3 ); // s= Hello Out

            (3) string 的后面加string(有兩種方法)

            basic _ string& append( const basic _ string& _Str );

            string s1 ( "Hello " ), s2 ( "Wide " ), s3( "World " );

            s1.append ( s2 ); // s1= Hello Wide

            s1 += s3; // s1= Hello Wide World

            (4) string 的后面加string 的一部分 ---A

            basic _ string& append( const basic _ string& _Str , size _ type _Off ,

            size _ type _Count );

            string s1 ( "Hello " ), s2 ( "Wide World " );

            s1.append ( s2 , 5 , 5 ); // s1= Hello World

            (5) string 的后面加string 的一部分 ---B

            template<class InputIterator> basic _ string& append(

            InputIterator _First , InputIterator _Last );

            string str1f ( "Hello " ), str2f ( "Wide World" );

            str1f.append ( str2f.begin ( ) + 5 , str2f.end ( ) );

            // s1= Hello World

            (6) string 的后面加多個字符

            basic _ string& append( size _ type _Count , value _ type _Ch );

            string str1e ( "Hello " );

            str1e.append ( 4 , '!' ); // s1= Hello !!!!

            basic_string::assign

            string 賦值。 (比“=”更靈活)

            (1) string C-string

            basic _ string& assign( const value _ type* _Ptr );

            string s;

            const char *c = "Out There";

            s.assign ( c ); // s= Out There

            (2) string C-string 的一部分

            basic _ string& assign( const value _ type* _Ptr , size _ type _Count );

            string s;

            const char *c = "Out There";

            s.assign ( c , 3 ); // s= Out

            (3) string string(有兩種方法)

            basic _ string& assign( const basic _ string& _Str );

            string s1 ( "Hello" ), s2 ( "Wide" ), s3( "World" );

            s1.assign ( s2 ); // s1= Wide

            s1 = s3; // s1= World

            (4) string string 的一部分 ---A

            basic _ string& assign( const basic _ string& _Str , size _ type off ,

            size _ type _Count );

            string s1 ( "Hello " ), s2 ( "Wide World " );

            s1.assign ( s2 , 5 , 5 ); // s1= Hello World

            (5) string string 的一部分 ---B

            template<class InIt> basic _ string& assign(

            InputIterator _First ,

            InputIterator _Last );

            string str1f ( "Hello " ), str2f ( "Wide World" );

            str1f.assign ( str2f.begin ( ) + 5 , str2f.end ( ) ); // s1= Wide World

            (6) string 賦 多個字符

            basic _ string& assign( size _ type _Count , value _ type _Ch );

            string str1e ( "Hello " );

            str1e.assign ( 4 , '!' ); // s1= !!!!


            引用地址:http://blog.programfan.com/trackback.asp?id=16880

            posted on 2006-09-04 18:47 HUYU 閱讀(8465) 評論(0)  編輯 收藏 引用

            亚洲国产精品无码久久久不卡| 99久久婷婷免费国产综合精品| 午夜精品久久久久久久无码| 亚洲精品美女久久久久99小说 | 久久久青草久久久青草| 久久成人永久免费播放| 日产精品久久久久久久| 99久久无码一区人妻| 一本一本久久a久久综合精品蜜桃 一本一道久久综合狠狠老 | 伊人丁香狠狠色综合久久| 久久香蕉综合色一综合色88| 无码任你躁久久久久久| 97久久香蕉国产线看观看| 色婷婷噜噜久久国产精品12p| 久久综合狠狠综合久久综合88| 欧美性猛交xxxx免费看久久久| 精品久久一区二区| 亚洲AV无码久久精品蜜桃| 久久亚洲AV无码西西人体| 久久国产乱子伦精品免费强| 日韩精品久久无码人妻中文字幕 | 国产精品99久久久久久人| 国产精品久久久久久久久软件| yellow中文字幕久久网| 久久精品国产91久久综合麻豆自制| 久久涩综合| 久久这里只有精品视频99| 久久久国产精品福利免费 | 97久久国产露脸精品国产| 久久久国产精华液| 国产免费福利体检区久久| 久久精品国产免费一区| 国产精品对白刺激久久久| 久久人人妻人人爽人人爽| 伊人久久精品无码av一区| 久久久久久伊人高潮影院| 久久久久久久97| 久久久久国产精品熟女影院| 久久九九精品99国产精品| 狠狠色丁香婷婷综合久久来| 久久久久久a亚洲欧洲aⅴ|