srand(time(NULL));
for (i = 4 - 1; i >= 0; i--)
{
// range is 0 - 9
// buf[i] temporary int array to hold the groups of 4
buf[i] = rand() % 10;
printf("digits: %d\n", buf[i]);
}
// Then I need to copy it to an int *numbers which is part of a
// struct
for (i = 4 - 1; i >=0; i--)
{
n->numbers[i] = buf[i];
//n->numbers[i+4] = buf[i];
printf("arr1: %d\n", n->numbers[i]);
}
Output:
0000000000000000000000000000000000001422
The first run outputs 1422 (it changes every time), but I need my program to keep taking different random #'s and adding it to the array until it's full (when it reaches 40). That's the problem I am having
Aucun commentaire:
Enregistrer un commentaire