// L-6 MCS 360 Fri 3 Sep 2010 : out_of_range.cpp

/* The user is prompted to enter a string and an index.

We use the index to select a character of the string twice:
(1) with the [] operator;
(2) with the at method of string. */
  
#include <iostream>
#include <string>
using namespace std;

int main()
{
   string s; 

   cout << "Give a string : "; cin >> s;

   int k;
   cout << "Give an index : "; cin >> k;

   cout << "char at " << k 
        << " : " << s[k] << endl;

   cout << "char at " << k 
        << " : " << s.at(k) << endl;

   return 0;
}

