title: Moving through every character in a string array
body: <p>I am trying to go through every string index and print the even indexes first and then print all the odd indexes. However I am getting a segmentation error and I don't know what it is caused by.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>int sum;
  vector&lt;string&gt; array;
  string temp;
  for (int i = 0; i &lt; num; i++) {
      cin &gt;&gt; array[i];
  }
  
  for (int i = 0; i &lt; num; i++) {
      temp = array[i];
      for (int j = 0; j &lt; temp.size(); j++) {
          sum = j;
          if (sum % 2 == 0) {
              cout &lt;&lt; array[i][j];
          }
      }
  }
  cout &lt;&lt; " ";
  for (int i = 0; i &lt; num; i++) {
      temp = array[i];
      for (int j = 0; j &lt; temp.size(); j++) {
          sum = j;
          if (sum % 2 != 0) {
              cout &lt;&lt; array[i][j];
          }
      }
  }
  </code></pre>
  
  <p>Does anyone see what I am doing wrong?</p>