Hash table nebudu implementovat, na to nemám čas, ale algoritmus generování jsem ti napsal, uprav si to podle zadání.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define WORD_MIN_LEN 1
#define WORD_MAX_LEN 10
#define WORDS_COUNT 500
int
main (void)
{
char words[WORDS_COUNT * (WORD_MAX_LEN + 1)];
unsigned int rnd_w_len, rnd_w_char, words_buff_pos;
int i, j;
srand (time (NULL));
memset (words, 0, sizeof (words));
words_buff_pos = 0;
for ( i = 0; i < WORDS_COUNT; i++ ){
// Generate random length within range
rnd_w_len = rand () % (WORD_MAX_LEN - WORD_MIN_LEN + 1) + WORD_MIN_LEN;
fprintf (stderr, "Generating a word of length: %u B\n", rnd_w_len);
for ( j = 0; j < rnd_w_len; j++ ){
// Generate a random character in range 97 - 122 (ASCII lowercase alphabet)
rnd_w_char = rand () % (122 - 97 + 1) + 97;
words[words_buff_pos++] = rnd_w_char;
}
words[words_buff_pos++] = '\0';
}
fprintf (stderr, "Generated words:\n");
words_buff_pos = 0;
for ( i = 0; i < WORDS_COUNT; i++ ){
fprintf (stdout, "%s\n", words + words_buff_pos);
words_buff_pos += strlen (words + words_buff_pos) + 1;
}
return EXIT_SUCCESS;
}