i need vector & srand help

I am making the beginnings of a dice game. I am starting to use vectors with srand and I am relatively new to them. In this game to start I need the vector to randomly choose 5 numbers between 1 through 6. And then later in the program I will count the frequencies of each number to output if you got 3 of a kind or 4 of a kind and so on. Right now it is only printing the numbers '5' and '6'. How do I get it to print random numbers between 1 through 6? here is what I have.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<vector>

using namespace std;

void fiveDice(vector<int> & v);
void printDice(vector<int> v);

int main()
{
    vector<int> first(5);
    
    fiveDice(first);
    printDice(first);
    
    system("PAUSE");
    return EXIT_SUCCESS;
}


void fiveDice(vector<int> & v)
{
     for(int i=0; i<v.size(); i++)
     {
         v[i] = 1+rand()%6;
     }
}
void printDice(vector<int> v)
{
     for(int i=0; i<v.size(); i++)
     {
         cout<<v[i]<<" ";
     }
     cout<<endl;    
}
You need to seed the random number generator with srand().
Should I just use:

srand( time(0) );
Yeah, put that right after main() and you should be good to go.
(i'd pass your vector by reference into your print method too).
Topic archived. No new replies allowed.