I'm not sure how to use vectors in C++. 
It has to do with the vector's push back technique. 
I used push back to insert entries into the vector in the first programme. 
I used at() to insert entries into the vector in the second application.
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main ()
{
  std::vector<string> myvector (3);
  cout << "In main" << endl;
  for (unsigned i=0; i<myvector.size(); i++)
  {
    myvector.push_back("hi");  //Note: using push_back here.
  }
  cout << "elements inserted into myvector" << endl;
  std::cout << "myvector contains:" << endl;
  for (auto v: myvector)
     cout << v << endl;
  // access 2nd element
  cout << "second element is " << myvector[1] << endl;
  return 0;
}
Output:   
Hangs after entering main.   
$ ./a.out   
In main
What is the problem with the way I used push back? 
This is one of the methods we use to put items into the vector, correct?