title: how to generate a 6 digit number - unique ID c++ code
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/440133/how-do-i-create-a-random-alpha-numeric-string-in-c">How do I create a random alpha-numeric string in C++?</a>  </p>
  </blockquote>
  
  
  
  <p>I need to create a 6 digit number. What should I use? Can someone give me a c++ code example?</p>
  
  <p>This is my code: (once in a while the number is repeating)</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  #include &lt;iostream&gt;
  using namespace std;
  int
  main (int argc, char *argv[])
  {
    /* Simple "srand()" seed: just use "time()" */
    unsigned int iseed = (unsigned int)time(NULL);
    srand (iseed);
  
    /* Now generate 5 pseudo-random numbers */
    int i;
    bool da=false;
    while (da==false)
    {if (rand ()%1000000&lt;=999999)
    {cout&lt;&lt;"random nr: "&lt;&lt;rand ()%1000000&lt;&lt;endl;
    da=true;
  }
  else da=false;
  }
   /* for (i=0; i&lt;5; i++)
    {
      printf ("rand[%d]= %u\n",
        i, rand ());
    }*/
    return 0;
  }
  </code></pre>
  
  <p>Thx
  Appreciate</p>