title: How to generate different random number for the same variable
body: <p>I want to use a while loop to generate a random number for a variable to spell out a scrambled word. My problem is that my code generates a number that is random but repeats that number rather than using a new number. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;ctime&gt;
  using namespace std;
  
  int main()
  {
      string wordList[5] = {"cool", "friend", "helpful", "amazing", 
  "person"};
      srand(time(0));
      int rWord = rand() % 5 + 1;
      string randWord = wordList[rWord];
      int runs = 0;
      int wordLen = randWord.length();
      while(runs != wordLen){
          int ranLN = rand() % wordLen;
          char randLetter = randWord[ranLN];
          cout &lt;&lt; randLetter;
          runs++;
  }
  
  return 0;
  }
  </code></pre>
  
  <p>I expected my results to be a fully scrambled word, but I instead got repeated letters. For example, I got the word "friend" scrambled as "eennn".</p>