strcpy(shuffle_text,answers[19]);shuffle_string(shuffle_text);for(i=0;i<maxans;i++){system("cls");original_text=answers[i];draw_boxes(answers,right_answers);printf("\t\t\t Text: %s\n",shuffle_text);printf("Score:%d\n",*easy_score);while(1){printf("Life Left %d\n",life);printf("Please enter your answer: \t");scanf("%s",user_input);found_answer=0;for(j=0;j<maxans;j++){if(strcmp(user_input,answers[j])==0){right_answers[j]=1;found_answer=1;len=strlen(answers[j]);if(len==5){*easy_score+=300;}elseif(len==4){*easy_score+=200;}elseif(len<=3){*easy_score+=50;}break;}}if(!found_answer){life-=1;if(life==0){gameover=1;}}printf("\n");break;}if(gameover){system("cls");displayall(answers);printf("\t\t\tGame over...\nThese are the correct answers\n");printf("\t\t\tBack to Main Menu?\n[1] - Yes\n[2] - No");scanf("%d",&opt2);if(opt2==1){printf("Going back to Main Menu");system("cls");if(*easy_score>*easy_highest){*easy_highest=*easy_score;strcpy(player_highest[i],player_name[i]);}}elseif(opt2==2){break;}break;}}if(*easy_score>*easy_highest){*easy_highest=*easy_score;strcpy(player_highest[i],player_name[i]);}
strcpy(shuffle_text,answers[24]);shuffle_string(shuffle_text);for(i=0;i<maxans;i++){system("cls");original_text=answers[i];draw_boxes(answers,right_answers);printf("\t\t\t Text: %s\n",shuffle_text);printf("\n\n");printf("Score:%d\n",*normal_score);while(1){printf("Life Left %d\n",life);printf("Please enter your answer: \t");scanf("%s",user_input);found_answer=0;for(j=0;j<maxans;j++){if(strcmp(user_input,answers[j])==0){right_answers[j]=1;found_answer=1;len=strlen(answers[j]);if(len==6){*normal_score+=500;}elseif(len==5){*normal_score+=300;}elseif(len==4){*normal_score+=200;}elseif(len<=3){*normal_score+=50;}break;}}if(!found_answer){life-=1;if(life==0){gameover=1;}}printf("\n");break;}if(gameover){system("cls");displayall(answers);printf("\t\t\tGame over...\nThese are the correct answers\n");printf("\t\t\tBack to Main Menu?\n[1] - Yes\n[2] - No");scanf("%d",&opt2);if(opt2==1){printf("Going back to Main Menu");system("cls");}elseif(opt2==2){break;}break;}}if(*normal_score>*normal_highest){*normal_highest=*normal_score;}
strcpy(shuffle_text,answers[29]);shuffle_string(shuffle_text);for(i=0;i<maxans;i++){system("cls");original_text=answers[i];draw_boxes(answers,right_answers);printf("\t\t\t Text: %s\n",shuffle_text);printf("\n\n");printf("Score:%d\n",*hard_score);while(1){printf("Life Left %d\n",life);printf("Please enter your answer: \t");scanf("%s",user_input);found_answer=0;for(j=0;j<maxans;j++){if(strcmp(user_input,answers[j])==0){right_answers[j]=1;found_answer=1;len=strlen(answers[j]);if(len==6){*hard_score+=500;}elseif(len==5){*hard_score+=300;}elseif(len==4){*hard_score+=200;}elseif(len<=3){*hard_score+=50;}break;}}if(!found_answer){life-=1;if(life==0){gameover=1;}}printf("\n");break;}if(gameover){system("cls");displayall(answers);printf("\t\t\tGame over...\nThese are the correct answers\n");printf("\t\t\tBack to Main Menu?\n[1] - Yes\n[2] - No");scanf("%d",&opt2);if(opt2==1){printf("Going back to Main Menu");system("cls");}elseif(opt2==2){break;}break;}}if(*hard_score>*hard_highest){*hard_highest=*hard_score;}
}
void draw_boxes(char answers[maxans][maxs],int right_answers[maxans]){
int i, j, len;
printf(" \t\t\t ____________________________\n");printf("\t\t\t| WORD TWISTER |\n");printf("\t\t\t|____________________________|\n");printf("\n");for(i=0;i<maxans;i++){printf("\t\t ");if(right_answers[i]){printf("%s",answers[i]);}else{len=strlen(answers[i]);for(j=0;j<len;j++){printf("__.");}}printf("\n");}
}
void displayall(char answers[maxans][maxs]){
int i, j, len;
It runs but crashes after i input the name of the player, i am still a beginner programmer so pardon my codes for being so messy.
include <time.h></time.h>
include <stdio.h></stdio.h>
include <stdlib.h></stdlib.h>
include <string.h></string.h>
define maxans 31
define easy_maxans 21
define maxs 10
void player(char player_name_ptr[maxs]);
int easy_start_game(char player_name[maxs][maxs],char player_highest[maxs][maxs],int easy_highest,int easy_score,int right_answers[maxans]);
int normal_start_game(int normal_highest,int normal_score,int right_answers[maxans]);
int hard_start_game(int hard_highest,int hard_score,int right_answers[maxans]);
void draw_boxes(char answers[maxans][maxs],int right_answers[maxans]);
void displayall(char answers[maxans][maxs]);
int get_random_number(int max);
void shuffle_string(char text);
int main()
{
}
void player(char* player_name_ptr[maxs]){
}
int easy_start_game(char player_name[maxs][maxs],char player_highest[maxs][maxs],int easy_highest,int easy_score,int right_answers[maxans]) {
char answers[easy_maxans][maxs] ={"alp","cap","lap","pal","act","alt","cat","lat","pat","apt","pac","tap",
"acta","paca","plat","clap","pact","talc","clap",
"clapt"};
int i,j,gameover=0,opt,opt2,life=5,found_answer=0,len,score=0;
char *original_text;
char shuffle_text[maxs];
char user_input[maxs];
}
int normal_start_game(int normal_highest,int normal_score,int right_answers[maxans]) {
char answers[maxans][maxs] ={"air","ear","ave","ran","van",
"ire","vina","near","earn","rain",
"rive","rave","vain","vein","vine",
"rein","naive","raven","riven","ravin",
"invar","naevi","naiver","vainer","ravine",};
int i,j,gameover=0,opt,opt2,life=5,found_answer=0,len,score=0;
char *original_text;
char shuffle_text[maxs];
char user_input[maxs];
}
int hard_start_game(int hard_highest,int hard_score,int right_answers[maxans]) {
char answers[maxans][maxs] ={"dear","ears","eras","seam","seem",
"ease","arms","sear","seer","arse",
"seed","armed","dears","erase","dream",
"derma","eased","meads","reads","smear",
"dreams","remade","seamer","seared","dermas",
"reamed","seamed","erased","edemas","madres",};
int i,j,gameover=0,opt,opt2,life=5,found_answer=0,len,score=0;
char *original_text;
char shuffle_text[maxs];
char user_input[maxs];
}
void draw_boxes(char answers[maxans][maxs],int right_answers[maxans]){
int i, j, len;
}
void displayall(char answers[maxans][maxs]){
int i, j, len;
}
int get_random_number(int max) {
srand(time(0));
// rand() generates a random number from 0 to 32767
return rand() % max;
}
void shuffle_string(char clue[maxans]) {
char temp;
int len = strlen(clue);
int i;
int j;
}