token = strtok((words[random]),search);
while(token!=NULL)
{
length=strlen(words[random]);
for( k=0;k
This is messed and not what you intend. Change it to something straight, e. g.:
for (k = 0, c = words[random]; token = strtok(c, search); c = NULL, ++k)
matrix[i][k] = token;