title: Getting random unique integers in C++
body: <p>I am bringing a formatted text file and putting different lines to my array in random positions. However, when I try to get <code>rand() % 8</code>, I get values that I have already had for previous ones. This causes me to lose some lines and leaving some parts of array blank.</p>
  
  <p>How should I modify it so I get unique values from 0 to 7 in random sequence?
  I am using only what I have learned in class and new stuff is not recommended by instructor.
  Please help me change the logic of this code.</p>
  
  <pre><code>void get_input(string (&amp;teams)[8][6]) {
      srand(time(NULL));
      string filename;
      double value;
      char buffer[100];
      int diffnum[8];
      string token;
      cout &lt;&lt; "Enter the input file: ";
      cin &gt;&gt; filename;
      ifstream infile;
      infile.open (filename.c_str());
      if (infile.is_open()) {
      int teamcounter = 0;
          while (infile.getline (buffer, 100) &amp;&amp; teamcounter &lt; 8) {
              int ran = rand()%8;
              for (int find = 0; find &lt; 8; find++) {
                  while (diffnum[find] == ran) {
                      ran = rand()%8;
                  }
              }
              diffnum[teamcounter] = ran;
              int counter = 0;
              token = strtok (buffer, ",");
              while (counter &lt; 3) {
                  if (counter == 0) {
                      teams[ran][counter] = token;
                      token = strtok (NULL, ", ");
                  }
                  else if (counter == 1) {
                      teams[ran][counter] = token;
                      token = strtok (NULL, ", ");
                  }
                  else {
                      teams[ran][counter] = token;
                  }
                  counter++;
              }
              teamcounter++;
          }
          infile.close();
      }
      else {
          cout &lt;&lt; "Unable to open file";
          exit (EXIT_FAILURE);
      }
      for (int q =0;q&lt;8;q++) {
          cout &lt;&lt; diffnum[q];
      }
      for (int i; i &lt; 8; i++) {
          for (int j = 3; j &lt; 6; j++){
              teams[i][j] = "0";
          }
      }
  }
  </code></pre>