This is the basic idea for making the list of strings (error checking omitted):
Code:
int main ( int argc, char *argv[] )
{
char **string_list;
int i;
int n;
int len;
if ( argc != 3 ) {
fprintf ( stderr, "usage: $ prog <n strings> <max len>\n" );
return EXIT_FAILURE;
}
n = atoi ( argv[1] );
len = atoi ( argv[2] );
string_list = malloc ( n * sizeof *string_list );
for ( i = 0; i < n; i++ )
string_list[i] = calloc ( len, sizeof *string_list[i] );
/* Work with your new array of strings */
for ( i = 0; i < n; i++ )
free ( string_list[i] );
free ( string_list );
return EXIT_SUCCESS;
}
For RandomString, something like this I suppose, you can get more efficient using table lookup, but I'm too lazy to type that up
Code:
#include <ctype.h>
#include <limits.h>
void RandomString ( char *string, int limit, int high )
{
int i;
for ( i = 0; i < limit; i++ )
string[i] = rand() % high;
}