I would like to have the user define the number of random numbers they would like to be stored in a member of my struct. Here is what I have so far.
struct BigInt {
int A;
int rdm;
};
struct BigInt A[300];
struct BigInt rdm[10]={0,1,2,3,4,5,6,7,8,9};
printf("Number");
int len;
scanf("%i",&len);
srand(time(NULL));
int i=0;
while (i!=len){
int r=rand()%10;
A[i]=rdm[r];
printf("\nr:%i\n",r);
printf("A[i]:%i",A[i]);
i++;
}
But I am getting strange values and it's not working as I expect it to be. I have no idea why, what am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire