Array in C Programming.

Im making a word quiz in C.First a person enter a secret word.
1
2
printf("Enter the secret words:");
scanf("%s",&secrt_word);


then another user will try to guess the word.

like this:
1
2
printf("Guess the word: ");
scanf("%c",&word_guess);


then ill will compare to the secret word with the guess word .So it will give you the amount of matching alphabets and the place of the alphabets that match the secret word.

the output is like this:
i enter smile
ENTER THE SECRET WORD:

a user enter shirt in the the quess word
GUESS the words:



then an output will appear like this

matching word:1
matching in placed:1


the problem is:
should i use function call?
how can i make the matching word and the matching in placed

Last edited on
are you talking about words or characters???

because if its words then smile and shirt doesnt match!!
for words matching you can use strcmp

for characters you can run a loop and compare the characters..
1
2
3
4
5
6
7
while(word1[i] && word2[i])
{
if(word1[i] == word2[i])
cout << "position: " << i << endl;

i++;
}
i mean there is a match in the alphabet..

like shirt and smile..

the same as in S

so this programme will loop until it get the correct answer..
Last edited on
Topic archived. No new replies allowed.