• <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)  編輯 收藏 引用

            成人综合久久精品色婷婷| 久久久久亚洲AV成人网人人网站| 一级A毛片免费观看久久精品| 色婷婷久久久SWAG精品| 欧美久久一级内射wwwwww.| 亚洲国产天堂久久综合网站 | 欧美久久久久久精选9999| 久久亚洲AV成人无码软件| 亚洲国产成人久久综合碰碰动漫3d| 久久久久国产一区二区| 亚洲午夜久久久影院伊人| 精品久久久久久综合日本| 久久WWW免费人成一看片| 久久久WWW成人免费精品| 久久久一本精品99久久精品88| 久久国产精品二国产精品| 精品久久无码中文字幕| 久久精品国产99久久久古代 | 久久精品国产久精国产果冻传媒| 999久久久免费国产精品播放| 婷婷伊人久久大香线蕉AV | 亚洲日本久久久午夜精品| 国产精品xxxx国产喷水亚洲国产精品无码久久一区| 一本一道久久a久久精品综合 | 久久一本综合| 久久av高潮av无码av喷吹| 久久成人影院精品777| 国产精品久久久久久久| 久久av无码专区亚洲av桃花岛| 超级97碰碰碰碰久久久久最新 | 亚洲精品无码专区久久久| 免费久久人人爽人人爽av| 婷婷国产天堂久久综合五月| 精品久久久久中文字| 久久久中文字幕日本| 亚洲国产精品成人久久蜜臀 | 日日噜噜夜夜狠狠久久丁香五月| 久久精品国产亚洲av麻豆图片| 国产精品乱码久久久久久软件| 久久国产亚洲精品| 亚洲中文字幕无码一久久区|