Help me guys. this is a part of my program and the scanf part doesn't function.
im using the Turbo C version.
the one that is bold is the part that doesn't work. can't locate my error. HELP!
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void startgame(char giver[], char guesser[], int life)
{
int ctr, run = 0, repeat, ok, correct;
char phrase[100], clue[100], display[100], guessed[100], choice, guess;
printf ("\nEnter the SECRET phrase %s: ", giver);
gets (phrase);
printf ("Enter the CLUE phrase %s: ", giver);
gets (clue);
system ("cls");
printf ("*******PHRASE GUESSING GAME*******\n\n");
printf ("The CLUE given by %s is: %s\n", giver, clue);
strcpy (display, phrase);
for (ctr = 0; ctr < 100 && phrase[ctr] != '\0'; ctr++)
{
if (phrase[ctr] == ' ')
{
display[ctr] = ' ';
}
else
{
display[ctr] = '-';
}
}
printf ("\nThe PHRASE %s need to guess is: %s", guesser, display);
while (life!=0)
{
printf ("\n\n%s, Enter the letter of your choice:\na. Guess a letter in the phrase\nb. Guess the phrase\nc. Surrender\nChoice: ", guesser);
scanf ("%c", &choice);
if (choice=='a')
{
printf ("\n\nYou chose a. Guess a letter in the phrase.\nEnter your guess letter: ");
scanf ("%c", &guess);
}
}
}
void main (void)
{
char name1[10], name2[10];
int turn = 1, life1 = 4, life2 = 4;
clrscr ();
printf ("*******PHRASE GUESSING GAME*******\n\n");
printf ("Enter Player 1's name: ");
gets (name1);
printf ("Enter Player 2's name: ");
gets (name2);
while (turn<=2)
{
if (turn==1)
{
startgame (name1, name2, life2);
}
if (turn==2)
{
startgame (name2, name1, life1);
}
turn++;
}
getch ();
}