title: Segmentation Fault while accepting input
body: <p>I am trying to accept the input from user
  where first line will be Integer to indicate number of testcases</p>
  <p>if number is 3</p>
  <p>Input will be like</p>
  <pre><code>3
  Hello world
  hey there, I am John
  have a nice day
  </code></pre>
  <p>I am using <code>getline</code> to read the input</p>
  <p>My code</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;algorithm&gt;
  
  using namespace std;
  
  int main(){
      int n;
      cin &gt;&gt; n;
  
      vector&lt;string&gt; arr;
  
      for(int i=0; i&lt;n; i++){
          string s;
          getline(cin, s);
          arr[i] = s;
      }
  }
  </code></pre>
  <p>Error:</p>
  <pre><code>3 
  
  Segmentation fault(core dumped)
  </code></pre>