The clue is in the error message. It says you passed it a "char **". That's what you should pass to it so the code should look like this :
int rand_choice_data_words(char ** for_data_words)
{
int length = sizeof(for_data_words) / sizeof(for_data_words[0]);
int pos = (rand() % (length - 1) + 1);
return pos;
}
int main(void)
{
srand(time(NULL));
char *data_words[] = {"knowledge","fantasy","inspiration","practice","construction","creation"};
int position = rand_choice_data_words(data_words);
printf("%s\n\n" , data_words[position]);
return 0;
}
Have you noticed that the only reason you passed in the array is so you could figure out how big it is? I think a better option is to figure that outside the function. Here is a way you can do this by counting :
int random_choice( int listSize )
{
int pos = rand() % listSize;
return pos;
}
int main(void)
{
char *words[] =
{
"knowledge"
, "fantasy"
, "inspiration"
, "practice"
, "construction"
, "creation"
, NULL
};
int count = 0;
int n;
srand( time(NULL) );
for( int n = 0; words[ n ] != NULL; ++n )
++count;
int position = random_choice( count );
printf("%s\n\n" , words[ position ] );
return 0;
}
This uses a NULL at the end of the list to act as a terminator. I think the random number algorithm was a little off too. If there are five items in a list indexes into can range from 0 to 4. The modulo operator with five will give results ranging from 0 to 4 also so there is no need to subtract from the number of words. You don't want to add one either or you will never use item 0 and item 5 is invalid.