Bibliothèque de chaînes C ++ - commencer

La description

Il renvoie un itérateur pointant sur le premier caractère de la chaîne.

Déclaration

Voici la déclaration pour std :: string :: begin.

iterator begin();
const_iterator begin() const;

C ++ 11

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

Paramètres

aucun

Valeur de retour

Il renvoie un itérateur au début de la chaîne.

Des exceptions

Ne jetez jamais d'exceptions.

Exemple

Dans l'exemple ci-dessous pour std :: string :: begin.

#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;
}

L'exemple de sortie devrait être comme ceci -

Tutorials point