-1
Why the function scrolled below always returns the same values when called multiple times, although Seed srand((unsigned)time(NULL)) has been initialized?
#include <time.h>
#include <stdio.h>
int rolaDados(int *a){
srand((unsigned)time(NULL));
int i = 0;
int temp = 0;
for(i=0;i<3;i++){
temp += 1 + rand()%6;
}
return(temp);
}
void main(){
int a=rolaDados(&a);
int b=rolaDados(&b);
int c=rolaDados(&c);
printf("%d\n%d\n%d",a,b,c);
}
Example of an exit:
13
13
13
--------------------------------