cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : Strings library : string : end
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
Strings library
char_traits
classes:
· string
global functions:
· getline
· operator+
· operator<<
· operator>>
· comparison operators
· swap
string
string::string
member constants:
· string::npos
member functions:
· string::append
· string::assign
· string::at
· string::begin
· string::capacity
· string::clear
· string::compare
· string::copy
· string::c_str
· string::data
· string::empty
· string::end
· string::erase
· string::find
· string::find_first_not_of
· string::find_first_of
· string::find_last_not_of
· string::find_last_of
· string::get_allocator
· string::insert
· string::length
· string::max_size
· string::operator+=
· string::operator=
· string::operator[]
· string::push_back
· string::rbegin
· string::rend
· string::replace
· string::reserve
· string::resize
· string::rfind
· string::size
· string::substr
· string::swap

-

string::end public member function
      iterator end();
const_iterator end() const;

Return iterator to end

Returns an iterator referring to the next element after the last character in the string.

Parameters

none

Return Value

An iterator past the end of the string.

The type of this iterator is either string::iterator member type or string::const_iterator member type, which are compiler specific iterator types suitable to iterate through the elements of a string object.

Example

// string::begin and string::end
#include <iostream>
#include <string>
using namespace std;

int main ()
{
  string str ("Test string");
  string::iterator it;
  for ( it=str.begin() ; it < str.end(); it++ )
    cout << *it;
  return 0;
}

This code prints out the content of a string character by character using an iterator that iterates between begin and end.

Basic template member declaration

( basic_string<charT,traits,Allocator> )
      iterator end();
const_iterator end() const;

See also

string::begin Return iterator to beginning (public member function)
string::rbegin Return reverse iterator to reverse beginning (public member function)
string::rend Return reverse iterator to reverse end (public member function)

Home page | Privacy policy
© cplusplus.com, 2000-2008 - All rights reserved - v2.2
Spotted an error? contact us