typedef struct digits
{
int *numbers; // 40 digit integer array malloc'd
} digits;
// Section of function (not global)
// Outer loop (loops 5 times)
for (i = 5 - 1; i >=0; i--)
{
// loops 40 times
for (j = 40 - 1; j >= 0; j--)
{
// generates random number. I mod by 16 because I'm dealing
// with hexadecimals
r -> numbers[j] = rand () % 16;
// If j is equal 5 store into array
if (j == 5)
{
}
}
}
Question: I don't know how to complete this function to do what I want it to do. I have an idea of how it starts, and I've put in stuff into the loops, but it doesn't give me the expected output. I don't know how to do it to store the same 5 digits over and over until it's 40. Don't worry too much about the hex values, they display appropriately, they just don't repeat 8 times.
rand() generated: 3 8 9 5 10
Expected Output: 3895a3895a3895a3895a3895a3895a3895a3895a
Aucun commentaire:
Enregistrer un commentaire