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

La description

Il renvoie const_iterator au début.

Déclaration

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

const_iterator cbegin() const noexcept;

C ++ 11

const_iterator cbegin() const noexcept;

Paramètres

aucun

Valeur de retour

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

Des exceptions

Ne jetez jamais d'exceptions.

Exemple

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

#include <iostream>
#include <string>

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

   return 0;
}

L'exemple de sortie devrait être comme ceci -

Tutorials Point