#include <iostream>
#include <string>




int main()
{

  // C++ string
  std::string stad = "Utrecht";
  std::cout << stad << std::endl;

  // char pointer pointing to string constant
  // char *provincie = "Gelderland"; // deprecated conversion
  char *provincie = (char *) "Gelderland";

  // C/C++ char array initialised with a string constant
  //char provincie[] = "Gelderland";

  /*
   * The next line only shows the first letter because provincie is
   *   an array of char
   */
  std::cout << *provincie << std::endl;

  // Change the first letter
  // This is only allowed in the [] case, not when using a pointer to a
  //  string constant
  //*provincie = 'H';

  // Create a pointer to address individual elements in the array
  char * provinciepointer = provincie;

  // Loop with a pointer that walks through the array
  std::cout << "Walking pointer" << std::endl;
  while(*provinciepointer != 0)
  {
    std::cout << *provinciepointer << std::endl;
    provinciepointer++;
  } // while


  // Loop with array-index
  std::cout << "Array-index" << std::endl;
  int index=0;
  while(provincie[index] != 0)
  {
    std::cout << provincie[index] << std::endl;
    index++;
  } // while


  // Loop with offset of base-pointer
  std::cout << "Loop with offset" << std::endl;
  index=0;
  while( *(provincie+index) != 0)
  {
    std::cout << *(provincie+index) << std::endl;
    index++;
  } // while

  return 0;
}

