I'm totally new to C Programming and I'm trying to create a Word Search .
I've got a list of words , where only 4 are randomly picked. These 4 words than are to be printed in a grid horizontally, vertically or diagonally, however I can only get them to print horizontally. I also must add that I have no idea on how the piece of code works so I really appreciate if someone kind enough can actually help me. So can anybody help me in the right direction to create the random words in a vertical and diagonal alignment ? https://i.stack.imgur.com/3tk2b.jpg
void putHorizzontalWord(char word[10])
{
int rRow, rCol , ok , i;
do
{
rRow = rand() % 10;
rCol = rand() % 10;
ok = 1;
if(rCol + strlen(word) < 10)
{
for(i = 0;i < strlen(word);i++)
{
if(puzzle[rRow][rCol + i] == ' ' ||
puzzle[rRow][rCol + i] == word[i])
{
puzzle[rRow][rCol + i] = word[i];
}
else
{
ok = 0;
}
}
}
else
{
ok = 0;
}
}
while(ok == 0);
}