目录

begin

描述 (Description)

它返回一个指向字符串第一个字符的迭代器。

声明 (Declaration)

以下是std :: string :: begin的声明。

   iterator begin();
const_iterator begin() const;

C++11

   iterator begin() noexcept;
const_iterator begin() const noexcept;

参数 (Parameters)

没有

返回值 (Return Value)

它将迭代器返回到字符串的开头。

异常 (Exceptions)

永远不要抛出任何例外

例子 (Example)

在下面的示例中为std :: string :: begin。

#include <iostream>
#include <string>
int main () {
   std::string str ("IOWIKI");
   for ( std::string::iterator it=str.begin(); it!=str.end(); ++it)
      std::cout << *it;
   std::cout << '\n';
   return 0;
}

样本输出应该是这样的 -

IOWIKI  
↑回到顶部↑
WIKI教程 @2018