Hello I'm writing a program that would generate 10 random characters in order to form a word (it's for a game).
so here's my function:
void GenerateTen(int number)
{
int i;
char abc[30]="abcdefghijklmnopqrstuvwxyz";
char newabc[8];
for (i = 0; i < number; ++i) {
newabc[i] = abc[rand() % (sizeof(abc) - 1)];
printf("%c ", newabc[i]);
}
newabc[number] = 0;
}
the number variable contains 10 and the output is supposed to simply print these 10 characters in the array. There's no error by the compiler however, the program generates the same set of characters. Thank you for your help! :-)