#include <string>
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
  string my_string;

  // Set the string
  my_string = "David Coppit";

  // Concatenate the string
  cout << "Concatenated: " << my_string + "'s STL string" << endl;

  // Get the length
  cout << "The length is: " << my_string.size() << endl;

  // Compare strings
  if (my_string == "David Coppit")
    cout << "String matches" << endl;

  // Get the C character-array version. (Sometimes needed)
  ifstream input_file;
  input_file.open(my_string.c_str());
  input_file.close();

  // Iterate using character iterators
  {
    string::const_iterator a_character;
    for (a_character = my_string.begin();
         a_character != my_string.end();
         a_character++)
    {
      cout << *a_character << "#";
    }
    cout << endl;
  }

  // Iterate using an integer index
  {
    for (int i = 0; i < my_string.size(); i++)
    {
      cout << my_string[i] << "#";
    }
    cout << endl;
  }

  return 0;
}

