Why are you taking the modulus of two twice? Actually, why do it at all? Usually the way rand is used is you define a range for your values and write it as
value = rand() % maxValue;
Then values will have a range of zero to maxValue. In the "what you have tried section", the first loop only serves the purpose of initializing the vector. This could be written as :
for( i = 0; i < valueCount; ++i )
{
int value = rand() % maxValue;
buffer.push_back( value );
}
You need to define the variables valueCount and maxValue to make this usable. The return of rand will range from 0 to RAND_MAX. You can initialize the vector to a given size with reserve(). If you know how many you are going to have that can be a good idea. Mostly for large numbers so there no reallocations.