⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cppstring_details.html

📁 标准c/c++帮助文档
💻 HTML
📖 第 1 页 / 共 2 页
字号:
  <LI>查找在字符串中第一个与str中的某个字符匹配的字符,返回它的位置。搜索从index开始,如果没找到就返回<STRONG>string::npos</STRONG>
  <LI>查找在字符串中第一个与str中的某个字符匹配的字符,返回它的位置。搜索从index开始,最多搜索num个字符。如果没找到就返回<STRONG>string::npos,</STRONG>
  <LI>查找在字符串中第一个与ch匹配的字符,返回它的位置。搜索从index开始。
  
</UL>
</P>
<I>相关主题:</I><BR>
<STRONG>
<A HREF="#find">find()</A>
  
</STRONG>
<HR>
<H2>
   <A NAME="find_first_not_of">find_first_not_of</A>
</H2>
<I>语法:</I>
<TABLE BGCOLOR="CCCCFF"><TR><TD><PRE>

  size_type find_first_not_of( const basic_string &str, size_type index = 0 );
  size_type find_first_not_of( const char *str, size_type index = 0 );
  size_type find_first_not_of( const char *str, size_type index, size_type num );
  size_type find_first_not_of( char ch, size_type index = 0 );
</PRE></TD></TR></TABLE>
<P>
  find_first_not_of()函数:
<UL>
  <LI>在字符串中查找第一个与str中的字符都不匹配的字符,返回它的位置。搜索从index开始。如果没找到就返回<strong>string::nops</strong>
  <LI>在字符串中查找第一个与str中的字符都不匹配的字符,返回它的位置。搜索从index开始,最多查找num个字符。如果没找到就返回<strong>string::nops</strong>
  
  <LI>在字符串中查找第一个与ch不匹配的字符,返回它的位置。搜索从index开始。如果没找到就返回<strong>string::nops</strong>    
</UL>
</P>
<I>相关主题:</I><BR>
<STRONG>
<A HREF="#find">find()</A>
  
</STRONG>
<HR>
<H2>
   <A NAME="find_last_of">find_last_of</A>
</H2>
<I>语法:</I>
<TABLE BGCOLOR="CCCCFF"><TR><TD><PRE>

  size_type find_last_of( const basic_string &str, size_type index = npos );
  size_type find_last_of( const char *str, size_type index = npos );
  size_type find_last_of( const char *str, size_type index, size_type num );
  size_type find_last_of( char ch, size_type index = npos );
</PRE></TD></TR></TABLE>
<P>
  find_last_of()函数:
<UL>
  <LI>在字符串中查找最后一个与str中的某个字符匹配的字符,返回它的位置。搜索从index开始。如果没找到就返回<strong>string::nops</strong>
  <LI>在字符串中查找最后一个与str中的某个字符匹配的字符,返回它的位置。搜索从index开始,最多搜索num个字符。如果没找到就返回<strong>string::nops</strong>
  
  <LI>在字符串中查找最后一个与ch匹配的字符,返回它的位置。搜索从index开始。如果没找到就返回<strong>string::nops</strong>
</UL>
</P>
<I>相关主题:</I><BR>
<STRONG>
<A HREF="#find">find()</A>
  
</STRONG>
<HR>
<H2>
   <A NAME="find_last_not_of">find_last_not_of</A>
</H2>
<I>语法:</I>
<TABLE BGCOLOR="CCCCFF"><TR><TD><PRE>

  size_type find_last_not_of( const basic_string &str, size_type index = npos );
  size_type find_last_not_of( const char *str, size_type index = npos);
  size_type find_last_not_of( const char *str, size_type index, size_type num );
  size_type find_last_not_of( char ch, size_type index = npos );
</PRE></TD></TR></TABLE>
<P>
  find_last_not_of()函数:
<UL>
  <LI>在字符串中查找最后一个与str中的字符都不匹配的字符,返回它的位置。搜索从index开始。如果没找到就返回<strong>string::nops</strong>
  <LI>在字符串中查找最后一个与str中的字符都不匹配的字符,返回它的位置。搜索从index开始,最多查找num个字符如果没找到就返回<strong>string::nops</strong>
  <LI>在字符串中查找最后一个与ch不匹配的字符,返回它的位置。搜索从index开始。如果没找到就返回<strong>string::nops</strong>
  </UL>
</P>
<I>相关主题:</I><BR>
<STRONG>
<A HREF="#find">find()</A>
  
</STRONG>
<HR>
<H2>
   <A NAME="get_allocator">get_allocator</A>
</H2>
<I>语法:</I>
<TABLE BGCOLOR="CCCCFF"><TR><TD><PRE>

  allocator_type get_allocator();
</PRE></TD></TR></TABLE>
<P>
  get_allocator()函数返回本字符串的配置器.</P>
<HR>
<H2>
   <A NAME="insert">插入(insert)</A>
</H2>
<I>语法:</I>
<TABLE BGCOLOR="CCCCFF"><TR><TD><PRE>

  <A HREF="iterators.html">iterator</A> insert( <A HREF="iterators.html">iterator</A> i, const char &ch );
  basic_string &insert( size_type index, const basic_string &str );
  basic_string &insert( size_type index, const char *str );
  basic_string &insert( size_type index1, const basic_string &str, size_type index2, size_type num );
  basic_string &insert( size_type index, const char *str, size_type num );
  basic_string &insert( size_type index, size_type num, char ch );
  void insert( <A HREF="iterators.html">iterator</A> i, size_type num, const char &ch );
  void insert( <A HREF="iterators.html">iterator</A> i, <A HREF="iterators.html">iterator</A> start, <A HREF="iterators.html">iterator</A> end );
</PRE></TD></TR></TABLE>
<P>
  insert()函数的功能非常多:
<UL>
  <LI>在迭代器i表示的位置前面插入一个字符ch,  
  <LI>在字符串的位置index插入字符串str,
  <LI>在字符串的位置index插入字符串str的子串(从<I>index2</I>开始,长num个字符),
  <LI>在字符串的位置index插入字符串str的num个字符<I></I>,
  <LI>在字符串的位置index插入num个字符ch的拷贝,
  <LI>在迭代器i表示的位置前面插入num个字符ch的拷贝<I></I>,
  <LI>在迭代器i表示的位置前面插入一段字符,从start开始,以end结束.
</UL>
</P>
<I>相关主题:</I><BR>
<STRONG>
<A HREF="#replace">replace()</A>
  
</STRONG>
<HR>
<H2>
   <A NAME="length">长度(length)</A></H2>
<I>语法:</I>
<TABLE BGCOLOR="CCCCFF"><TR><TD><PRE>

  size_type length();
</PRE></TD></TR></TABLE>
<P>
  length()函数返回字符串的长度.  这个数字应该和<A HREF="#size">size()</A>返回的数字相同.</P>
<I>相关主题:</I><BR>
<STRONG>
<A HREF="#size">size()</A>
  
</STRONG>
<HR>
<H2>
   <A NAME="max_size">max_size</A>
</H2>
<I>语法:</I>
<TABLE BGCOLOR="CCCCFF"><TR><TD><PRE>

  size_type max_size();
</PRE></TD></TR></TABLE>
<P>
  max_size()函数返回字符串能保存的最大字符数。</P>
<HR>
<H2>
   <A NAME="rbegin">rbegin</A>
</H2>
<I>语法:</I>
<TABLE BGCOLOR="CCCCFF"><TR><TD><PRE>

  const <A HREF="iterators.html">reverse_iterator</A> rbegin();
</PRE></TD></TR></TABLE>
<P>
   rbegin()返回一个逆向<A HREF="iterators.html">迭代器</A>,指向字符串的最后一个字符。</P>
<I>相关主题:</I><BR>
<STRONG>
<A HREF="#rend">rend()</A>
  
</STRONG>
<HR>
<H2>
   <A NAME="rend">rend</A>
</H2>
<I>语法:</I>
<TABLE BGCOLOR="CCCCFF"><TR><TD><PRE>

  const <A HREF="iterators.html">reverse_iterator</A> rend();
</PRE></TD></TR></TABLE>
<P>
  rend()函数返回一个逆向<A HREF="iterators.html">迭代器</A>,指向字符串的开头(第一个字符的前一个位置)。</P>
<I>相关主题:</I><BR>
<STRONG>
<A HREF="#rbegin">rbegin()</A>
  
</STRONG>
<HR>
<H2>
   <A NAME="replace">替换(replace)</A>
</H2>
<I>语法:</I>
<TABLE BGCOLOR="CCCCFF"><TR><TD><PRE>

  basic_string &replace( size_type index, size_type num, const basic_string &str );
  basic_string &replace( size_type index1, size_type num1, const basic_string &str, size_type index2,
  size_type num2 );
  basic_string &replace( size_type index, size_type num, const char *str );
  basic_string &replace( size_type index, size_type num1, const char *str, size_type num2 );
  basic_string &replace( size_type index, size_type num1, size_type num2, char ch );
  basic_string &replace( <A HREF="iterators.html">iterator</A> start, <A HREF="iterators.html">iterator</A> end, const basic_string &str );
  basic_string &replace( <A HREF="iterators.html">iterator</A> start, <A HREF="iterators.html">iterator</A> end, const char *str );
  basic_string &replace( <A HREF="iterators.html">iterator</A> start, <A HREF="iterators.html">iterator</A> end, const char *str, size_type num );
  basic_string &replace( <A HREF="iterators.html">iterator</A> start, <A HREF="iterators.html">iterator</A> end, size_type num, char ch );
</PRE></TD></TR></TABLE>
<P>
  replace()函数:
<UL>
  <LI>用str中的num个字符替换本字符串中的字符<I></I>,从index开始
  <LI>用str中的num2个字符(从index2开始)替换本字符串中的字符,从index1开始,最多num1个字符
  
  <LI>用str中的num个字符(从index开始)替换本字符串中的字符
  
  <LI>用str中的num2个字符(从index2开始)替换本字符串中的字符,从index1开始,num1个字符
  
  <LI>用num2个ch字符替换本字符串中的字符,从index开始
  
  <LI>用str中的字符替换本字符串中的字符,迭代器start和end指示范围
  <LI>用str中的num个字符替换本字符串中的内容,迭代器start和end指示范围,
  <LI>用num个ch字符替换本字符串中的内容,迭代器start和end指示范围.
</UL>
  例如,以下代码显示字符串"They say he carved it himself...find 
  your soul-mate, Homer."
  <PRE>
    string s = "They say he carved it himself...from a BIGGER spoon";
    string s2 = "find your soul-mate, Homer.";

    s.replace( 32, s2.length(), s2 );

    cout << s << endl;
  </PRE>
</P>
<I>相关主题:</I><BR>
<STRONG>
<A HREF="#insert">insert()</A>
  
</STRONG>
<HR>
<H2>
   <A NAME="reserve">保留空间(reserve)</A>
</H2>
<I>语法:</I>
<TABLE BGCOLOR="CCCCFF"><TR><TD><PRE>

  void reserve( size_type num );
</PRE></TD></TR></TABLE>
<P>
  reserve()函数设置本字符串的<A HREF="#capacity">capacity</A> 以保留num个字符空间。 </P>
<I>相关主题:</I><BR>
<STRONG>
<A HREF="#capacity">capacity()</A>
</STRONG>

<HR>
<H2>
   <A NAME="resize">resize</A>
</H2>
<I>语法:</I>
<TABLE BGCOLOR="CCCCFF"><TR><TD><PRE>

  void resize( size_type num );
  void resize( size_type num, char ch );
</PRE></TD></TR></TABLE>
<P>
  resize()函数改变本字符串的大小到<I>num</I>, 新空间的内容不确定。也可以指定用ch填充。</P>
<HR>
<H2>
   <A NAME="rfind">rfind</A>
</H2>
<I>语法:</I>
<TABLE BGCOLOR="CCCCFF"><TR><TD><PRE>

  size_type rfind( const basic_string &str, size_type index );
  size_type rfind( const char *str, size_type index );
  size_type rfind( const char *str, size_type index, size_type num );
  size_type rfind( char ch, size_type index );
</PRE></TD></TR></TABLE>
<P>
  rfind()函数:
<UL>
  <LI>返回最后一个与str中的某个字符匹配的字符,从index开始查找。如果没找到就返回<strong>string::npos</strong>
  
  <LI>返回最后一个与str中的某个字符匹配的字符,从index开始查找,最多查找num个字符。如果没找到就返回<strong>string::npos</strong>
  
  <LI>返回最后一个与ch匹配的字符,从index开始查找。如果没找到就返回<strong>string::npos</strong>
</UL>
  例如,在下列代码中第一次调用rfind()返回<STRONG>string::npos</STRONG>,因为目标词语不在开始的8个字符中。然而,第二次调用返回9,因为目标词语在开始的20个字符之中。
  <PRE>
    int loc;
    string s = "My cat's breath smells like cat food.";

    loc = s.rfind( "breath", 8 );
    cout << "The word breath is at index " << loc << endl;

    loc = s.rfind( "breath", 20 );
    cout << "The word breath is at index " << loc << endl;
  </PRE>
</P>
<I>相关主题:</I><BR>
<STRONG>
<A HREF="#find">find()</A>
  
</STRONG>
<HR>
<H2>
   <A NAME="size">size</A>
</H2>
<I>语法:</I>
<TABLE BGCOLOR="CCCCFF"><TR><TD><PRE>

  size_type size();
</PRE></TD></TR></TABLE>
<P>
size()函数返回字符串中现在拥有的字符数。</P>
<I>相关主题:</I><BR>
<STRONG>
<A HREF="#length">length()</A>,
<A HREF="#max_size">max_size()</A>
  
</STRONG>
<HR>
<H2>
   <A NAME="substr">substr</A>
</H2>
<I>语法:</I>
<TABLE BGCOLOR="CCCCFF"><TR><TD><PRE>

  basic_string substr( size_type index, size_type num = npos );
</PRE></TD></TR></TABLE>
<P>
  substr()返回本字符串的一个子串,从index开始,长num个字符。如果没有指定,将是默认值  <STRONG>string::npos</STRONG>。这样,substr()函数将简单的返回从index开始的剩余的字符串。</P>
<P>例如:</P>
<PRE>
    string s("What we have here is a failure to communicate");

    string sub = s.substr(21);

    cout << "The original string is " << s << endl;
    cout << "The substring is " << sub << endl;
</PRE>
<P>
  显示:</P>
<PRE>
    The original string is What we have here is a failure to communicate
    The substring is a failure to communicate
</PRE>
<HR>
<H2>
   <A NAME="swap">交换(swap)</A>
</H2>
<I>语法:</I>
<TABLE BGCOLOR="CCCCFF"><TR><TD><PRE>

  void swap( basic_string &str );
</PRE></TD></TR></TABLE>
<P>
  swap()函数把str和本字符串交换。例如:</P>
<PRE>
    string first( "This comes first" );
    string second( "And this is second" );
    first.swap( second );
    cout << first << endl;
    cout << second << endl;
</PRE>
<P>显示:</P>
<PRE>
    And this is second
    This comes first
</PRE>
</BODY>
</HTML>
<br><html>
  <head>
    <meta http-equiv='Content-Type' content='text/html' charset='ISO_8859_1'>
    <title>131</title>
  <style>
  <!--
div#StrBanner /* Creates Nonscrolling banner region */
	{
	position: relative;
	left: 0px;
	padding: 0px 0px 0px 0px;
	border-bottom: 1px solid #999999;
	background-color: #99ccff;
	}
div#titlerow /* <!-- 131 --> */
	{
	padding: 0px 10px 0px 22px; 
	}
h1, h2, h3, h4 /* <!-- 131 --> */
	{
	font-family: Verdana, Arial, Helvetica, sans-serif;
	margin-bottom: .4em; 
	margin-top: 0em;
	font-weight: bold;
	}
	--> 
  </style>          
   </head>
   <body><!-- 131 -->
      <div id='StrBanner'>
         <div>
            <table class='TableBanner' cellspacing='0'>
               <tr>
                  <td ALIGN=RIGHT><!-- 131 --></td>
                  <td ALIGN=RIGHT><!-- 131 --></td> </tr>
            </table>
         </div>
         <div id='TitleRow'>
            <h3>Extr<!-- 131 -->acted by <!-- 131 -->Tria<!-- 131 -->l version of Ch<!-- 131 -->mDecom<!-- 131 -->piler<!-- 131 --> (<a href="http://www.etextwizard.com/download/cd/cdsetup.exe" target=_blank>Download Now</a>).</h3>   
            <h4>Once reg<!-- 131 -->istered, <!-- 131 -->all restrictions of the Tr<!-- 131 -->ial version are removed.</h4> 
            <a href="http://www.zipghost.com/order_chmdecompiler.html" target=_blank><H3>B<!-- 131 -->uy Now</H3></a>        
         </div>
      </div>
      <p><!-- 131 -->
      </p>
  </body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -