title: Printing out strings stored in a vector
body: <p>this is a basic question but I'm new to C++ so apologies in advance :)</p>
  
  <p>I couldn't seem to print out the strings I stored in a vector. I have used std:: cout as well as printf but printf seems to give the error "The program has stopped working". Where am I going wrong? </p>
  
  <p>Here's the code with std::cout :- </p>
  
  <pre><code>   #include &lt;iostream&gt; 
     #include &lt;cstdio&gt;         
     #include &lt;vector&gt; 
     #include &lt;fstream&gt; 
     using namespace std;
  
      int main(){ 
       int np; 
       string temp;  
  
       scanf("%d", &amp;np); 
       vector &lt;int&gt; money;
       vector &lt;string&gt; names;  
  
          for(int i = 0; i&lt; np; i++){
            scanf("%s", &amp;temp); 
            names.push_back(temp); 
            cout &lt;&lt; names[i] &lt;&lt; endl; 
         } 
  
     return 0;
     }
  </code></pre>
  
  <p>This didn't return any string at all. </p>
  
  <p>The other program I tried with printf is exactly the same, except the cout line is replaced with:</p>
  
  <pre><code>printf("%s", &amp;names[i]); 
  </code></pre>