Question: i have this problem and i post it many time and we give me a false solution and i try this Please help me this
i have this problem and i post it many time and we give me a false solution and i try this Please help me



this is my code Please help
#include
do { printf("Choose a category : "); printf(" 1. Food. 2. Objects. 3. Names. 4. Colors. "); scanf("%d",&menu3);
switch(menu3) { case 1 : fp = fopen("food.txt", "r"); // read mode break;
case 2 : fp = fopen("objects.txt", "r"); // read mode break; case 3 : fp = fopen("names.txt", "r"); // read mode break; case 4 : fp = fopen("colors.txt", "r"); // read mode break;
default: printf("Invalid Choose Please Try Again ! "); break ;
}
srand(time(NULL)); int x = rand() % 15;
int k = 0; while ((read = getline(&line, &len, fp)) != -1) {
if (k == x) break;
k++; }
char *a = line; char c[5], b; int i = 0, j = 0, d = 0, l = 0, e = 0, ch = 5, f = 0; l = strlen(a); printf("Guess Word : ");
for (i = 0; i
while (d != l) { printf(" Enter a character : ");
scanf("%c", &c);
e = d;
for (j = 0; j
for (j = 0; j
printf(" ");
if (e == f) { if (ch == 0) { printf(" Sorry you have no more choices "); break;
}
printf("You have %d choices ", ch); --ch; } f = e; } } while(1);
return 0; }
Task Five Modify the program you have to update the function startHangmanGame to implement the Hangman game, which works as follows: The program asks the user to select a category from one of the following: 1. Food 2. Objects. 3. Names. 4. Colors. As shown in Figure 8. Choose a category: 1. Food. 2. Objects. 3. Names. 4. Colors. Figure 8 If the user enters one of the 4 numbers, the program will select a word from that category to play. If the user enters any other number, the program will display an error message "Invalid choice." and redisplay the categories and wait for a valid choice. The program will use the provided files [food.txt, objects.txt, names.txt, colors.txt] which contain 15 words each to select a word from the user-selected category. The selected word should be chosen in random. You can use the rand function to generate random numbers in C, here is an example: #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
