im writing a program for practice that writes 1000 random words to an output file. the random words dont have to actual words just a bunch of lower case letters strung together in random lengths of 3 - 9 letters.
im guessing that i would need to generate random numbers 0-25 and then add 65 to correlate them to ascii. I dont know what function to use to generate random numbers between 0 and 25 and i cant really figure out how to add them together in random lengths of 3 - 9 letters.
here is my attempt:
Code:
void rand_words() {
int i = 0, j = 0;
int rand_num = 0;
int n;
char word[10];
for( i=0; i<=1000; i++) {
n = random_num_gen(0-25); // not a clue...
n += 65;
// need a line to convert numbers to letters
rand_num = random_num_gen(3-9); // again, no idea what this function needs to be
for( j=0; j<=rand_num; j++) {
word += n;
}
fprintf("%s\n", word)
}
}
i havent even tried to compile this but im pretty sure i got most of what i need