// strings.cc
#include <iostream>
#include <locale>
#include <algorithm>   // wegen reverse
#include <string.h>
using namespace std;
int main() {
  string s(10, ' ');           // Create a string of ten blanks.
  string t = "Äh";
  const char* A = "this is a test";
  setlocale(LC_ALL, "de_DE.utf8");
  s[0] = 'B';
  s[1] = 'c';
  s += A;
  cout << "s = " << (s + '\n');
  cout << "As a null-terminated sequence: " << s.c_str() << "\n";
  cout << "The sixteenth character is    \'" << s[15] << "\'\n\n";
  cout << "Empty ? : " << s.empty() << "\n";
  cout << "Position von \'t\' : " << s.find('t') << "\n\n";

  cout << "compare : ";
  if ( s.compare(t) < 0 )   // s < t ? Durch locale nicht beeinflusst
    cout << s << " <  " << t << "\n";
  else
    cout << s << " >= " << t << "\n";
 
  cout << "strcoll : ";
  if ( strcoll (s.c_str() , t.c_str()) < 0 )
    cout << s << " <  " << t << "\n";
  else
    cout << s << " >= " << t << "\n";

  cout << "Laenge von s   : " << s.length() << "\n";
  cout << "Capacity von s : " << s.capacity() << "\n";
  cout << "strlen(s)      : " << strlen(s.c_str()) << "\n";
  reverse(s.begin(), s.end());
  cout << "\nReverse : \n";
  s.push_back('\n');
  s.push_back('\n');
  cout << s;
}
