title: Sentence generator
body: <p>I am new to C++ and I'm doing a little project where I have to generate a sentence by using strings from array. The problem is that sometimes a string from the same array is ran twice even though the calculation moves from one array to the next, or sometimes the array is completely skipped. here are some examples the code prints: </p>
  
  <pre><code>some cat ran drove the shop. //here the verb[] array is ran twice
  some girl town on a boy. //here the nounPerson[] array is run but immediately the nounPlace[] array is ran next, instead of verb[] array like I tried to do in the code
  the the ran over the boy //here the same thing happens, the first word is printed twice and the nounPerson[] is skipped
  </code></pre>
  
  <p>Maybe my understanding of arrays is wrong, or maybe it's the random number generator. Here is my code</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;cstdlib&gt;
  #include &lt;ctime&gt;
  
  using namespace std;
  int main()
  {
      string article[5] = {"the ", "a ", "one ", "some ", "my "};
      string nounPerson[5] = {"boy ", "girl ", "dog ", "cat ", "person "};
      string nounPlace[5] = {"town ", "cafe ", "shop ", "store ", "house "};
      string verb[5] = {"drove ", "jumped ", "ran ", "walked ", "striked "};
      string preposition[5] = {"to ", "from ", "over ", "across ", "on "};
      string sentence;
      int word, word1, word2, word3, word4, word5;
  
      srand(time(0));
  
      word = rand() % 6;
      word1 = rand() % 6;
      word2 = rand() % 6;
      word3 = rand() % 6;
      word4 = rand() % 6;
      word5 = rand() % 6;
  
      //this is where the strings from the arrays add up to make a sentence
      sentence = article[word];
      sentence = sentence + nounPerson[word1];
      sentence = sentence + verb[word2];
      sentence = sentence + preposition[word3];
      sentence = sentence + article[word4];
      sentence = sentence + nounPlace[word5];
  
      cout &lt;&lt; sentence &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Also sometimes I get std::bad_alloc error and I have no idea what that is/how to fix that</p>