Shuffle function not working

Can anyone help me figure out what's wrong with my shuffle function?

It shuffles some songs, yet completely gets rid of others.

Here's the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void shuffle() //Shuffles songs into a random order.
{
   Music temp, temp2; //Temporary music file holders, 'Music' is a struct with string title;, string artist;, and int size;.
   unsigned int currentTime = (unsigned)time(0);

   srand(currentTime);

   for (int i = 0; i < NUM_SONGS; i++)
   {
      songs[i] = temp;
	  i = (rand() % NUM_SONGS);
	  songs[i] = temp2;
	  temp = songs[i];
	  i = (rand() % NUM_SONGS);
	  temp2 = songs[i];
   }
}


I want it to output this:
1
2
3
4
5
6
7
8
1. Title: Runaway2, Artist: Bon Jovi2, 2 MB
2. Title: Runaway5, Artist: Bon Jovi5, 5 MB
3. Title: Runaway1, Artist: Bon Jovi1, 2 MB
4. Title: Runaway4, Artist: Bon Jovi4, 1 MB
5. Title: Runaway7, Artist: Bon Jovi7, 5 MB
6. Title: Runaway6, Artist: Bon Jovi6, 5 MB
7. Title: Runaway3, Artist: Bon Jovi3, 5 MB
8. Title: Runaway8, Artist: Bon Jovi8, 1 MB

Or something along those lines, but instead I get something like this:
1
2
3
4
5
6
7
8
1. Title: Runaway7, Artist: Bon Jovi7, 1 MB
2. Title: Runaway2, Artist: Bon Jovi2, 2 MB
3. Title: Empty, Artist: Empty, 1856312448 MB
4. Title: Runaway4, Artist: Bon Jovi4, 1 MB
5. Title: Runaway5, Artist: Bon Jovi5, 5 MB
6. Title: Empty, Artist: Empty, 0 MB
7. Title: Runaway7, Artist: Bon Jovi7, 1 MB
8. Title: Empty, Artist: Empty, 1856312448 MB


And to make things clear, my professor wants us to use a loop, not a "shuffle" function.
Topic archived. No new replies allowed.