im trying to print the array 5 times, each time containing different numbers but it repeats the same random numbers. help please.
while(count<5){
fillarr2(ran1,ran2);
printar(ran1,ran2,counting);
}
// functions
void fillarr2(int raa[],int rab[]){
int ran1,ran2, i,count=0;
srand(time(NULL));
for(i=0;i<10;i++){
ran1=rand()%15+1;
raa[i]=ran1;
}
for(i=0;i<10;i++){
ran2=rand()%15+1;
rab[i]=ran2;
}
return ;
}
void printar(int x1[],int x2[],int cc){
int i,ran,ran2;
cout<<" 1st array holds ";
outfile<<" 1st array holds ";
for(i=0;i<cc;i++){
cout<<x1[i]<<" ";
outfile<<x1[i]<<" ";
}
cout<<endl;
outfile<<endl;
cout<<" 2nd array holds ";
outfile<<" 2nd array holds ";
for(i=0;i<cc;i++){
cout<<x2[i]<<" ";
outfile<<x2[i]<<" ";
}
cout<<endl;
cout<<endl;
outfile<<endl;
outfile<<endl;
return;
}
everytime it runs in the main the same random numbers are displayed, the generator works but only once.