title: c++ iterate through a vector of strings
body: <p>So I recently discovered the use of map and vectors, however, I'm having trouble of trying to figure a way to loop through a vector containing strings.</p>
  
  <p>Here's what I've tried:</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;stdio&gt;
  
  using namespace std;
  
  void main() {
      vector&lt;string&gt; data={"Hello World!","Goodbye World!"};
  
      for (vector&lt;string&gt;::iterator t=data.begin(); t!=data.end(); ++t) {
          cout&lt;&lt;*t&lt;&lt;endl;
      }
  }
  </code></pre>
  
  <p>and when I try to compile it, I get this error:</p>
  
  <pre><code>cd C:\Users\Jason\Desktop\EXB\Win32
  wmake -f C:\Users\Jason\Desktop\EXB\Win32\exbint.mk -h -e
  wpp386 ..\Source\exbint.cpp -i="C:\WATCOM/h;C:\WATCOM/h/nt" -w4 -e25 -zq -od    -d2 -6r -bt=nt -fo=.obj -mf -xs -xr
  ..\Source\exbint.cpp(59): Error! E157: col(21) left expression must be integral
  ..\Source\exbint.cpp(59): Note! N717: col(21) left operand type is 'std::ostream watcall (lvalue)'
  ..\Source\exbint.cpp(59): Note! N718: col(21) right operand type is 'std::basic_string&lt;char,std::char_traits&lt;char&gt;,std::allocator&lt;char&gt;&gt; (lvalue)'
  Error(E42): Last command making (C:\Users\Jason\Desktop\EXB\Win32\exbint.obj) returned a bad status
  Error(E02): Make execution terminated
  Execution complete
  </code></pre>
  
  <p>I tried the same method using map and it worked. The only difference was I changed the cout line to:</p>
  
  <pre><code>cout&lt;&lt;t-&gt;first&lt;&lt;" =&gt; "&lt;&lt;t-&gt;last&lt;&lt;endl;
  </code></pre>