Hello everyone,
I studied C/C++ a long time ago, and I want to relearn it...to do so I was trying to do a die game. You enter how many players are playing, and with a loop I generate 2 random numbers for each player...my problem is that the random numbers are the same for all the players... can someone help me on that? here is my code:
thanks for your help#include<iostream>
#include<stdlib.h>
#include<time.h>
using namespace std;
int main()
{
int player,x,a,b;
cout<<"number of players: \n";
cin>>player;
for (x=1;x<=player; x++)
{
cout<<"player"<<x<<"\n";
srand(time(NULL));
a=rand() % 6 + 1;
b=rand() % 6 +1;
cout<<"your first die is " <<a<< "\n";
cout<<"your second die is " <<b<< "\n";
cout<<"your total is "<<a+b<< "\n";
}
cin.ignore();
cin.get();
return 0;
}