I'm writing a function in C that generates a sequence of random integers given the length of the sequence. I've noticed that with numbers >66 the stdout shows "-" in between sets of numbers. How do I remove this and simply get a long string of integers? Here is my segment of code and the stdout: 1:
void gen_seq(int upper, int lower, int length) {
srand((unsigned) time(NULL));
char seq[length];
int i, n;
for (i = 0; i < length; i++) {
n = (rand() % (upper - lower + 1)) + lower; // range of numbers to generate numbers from
if (n != "-")
seq[i] = n;
}
for (i = 0; i < length; i++)
printf("%d", seq[i]);
printf("\n");
}
Aucun commentaire:
Enregistrer un commentaire