/*
    string.cpp how to define, read and print strings.

    See Nyhoff P55 for representation of strings
               P228 for more details on strings class.
               
    http://www.cplusplus.com/reference/string/
*/

#include <iostream>           // Include cin / cout streams for input/output
#include <string>             // include string type
using namespace std;

int main()
{         
   string name;                           // string is a sequence of characters (ASCII)

   cout << "Please write your name:";
   cin  >> name;                          // read string from keyboard until space/enter
   cout << "Hello " << name << "\n";      // print out string

   for (int i=0;i<name.length();i++)
      {
         char letter=name[i];
         cout << i << " is " << letter << " and ascii code is " << int(name[i]) << "\n";
      }

   return 0;
}
