C++ 字串庫 - end



描述

它返回一個指向字串第一個字元的迭代器。

宣告

以下是 std::string::end 的宣告。

   iterator end();
const_iterator end() const;

C++11

   iterator end() noexcept;
const_iterator end() const noexcept;

引數

返回值

它返回一個指向字串末尾之後的迭代器。

異常

從不丟擲任何異常。

示例

以下為 std::string::end 的示例。

#include <iostream>
#include <string>

int main () {
   std::string str ("Tutorials Point");
   for ( std::string::iterator it=str.begin(); it!=str.end(); ++it)
      std::cout << *it;
   std::cout << '\n';

   return 0;
}

示例輸出應如下所示:

Tutorials point  
string.htm
廣告