OK well use the following functions
- fgets - to read input from the user (use the file stdin)
- atoi or strtoul - convert user data to a binary number
- malloc - to allocate data for the string, remember you will need to terminate the string with a NULL ('\0') character so allocate 1 more slot than the user requests.
- [b]free - to free the the allocated data before the end of the program once you have finished with it
- srand - to seed the random number generator, people often use the return value from time to get a seed value
- rand - to get a random number, this will be in the range 0 - RAND_MAX and you will need to scale it to the range you require.
You will also need to know how arrays work.
I suggest you look all that up, then when you have made an attempt post it here and we will help you debug it.