I'm currently trying to create a little game in C and wanted to produce a little prototype where it would print a random word, make the user type the word, then it will show them how they typed it and then it will show the user how it should be typed.
The reason I want to show the user what they typed is so that at the end they can be an overview but right now I would just like to get it working.
Currently instead of displaying what the user put it shows numbers and I think that it has to do with the array in which I put the words but I have no idea. How can I get it to print the word in the array? Here's the code:
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
void main()
{
char *words[] = {"sausage","blubber","pencil","cloud","moon","water","computer","school","network","hammer","walking","violently","mediocre","literature","chair","two","window","cords","musical","zebra","xylophone","penguin","home","dog","final","ink","teacher","fun","website","banana","uncle","softly","mega","ten","awesome","attatch","blue","internet","bottle","tight","zone","tomato","prison","hydro","cleaning","telivision","send","frog","cup","book","zooming","falling","evily","gamer","lid","juice","moniter","captain","bonding","loudly","thudding","guitar","shaving","hair","soccer","water","racket","table","late","media","desktop","flipper","club","flying","smooth","monster","purple","guardian","bold","hyperlink","presentation","world","national","comment","element","magic","lion","sand","crust","toast","jam","hunter","forest","foraging","silently","tawesomated","joshing","pong","RANDOM","WORD"};
char *questions[] = {"sausage1","blubber1","pencil1","cloud1","moon1","water1","computer1","school1","network1","hammer1","walking1","violently1","mediocre1","literature1","chair1","two1","window1","cords1","musical1","zebra1","xylophone1","penguin1","home1","dog1","final1","ink1","teacher1","fun1","website1","banana1","uncle1","softly1","mega1","ten1","awesome1","attatch1","blue1","internet1","bottle1","tight1","zone1","tomato1","prison1","hydro1","cleaning1","telivision1","send1","frog1","cup1","book1","zooming1","falling1","evily1","gamer1","lid1","juice1","moniter1","captain1","bonding1","loudly1","thudding1","guitar1","shaving1","hair1","soccer1","water1","racket1","table1","late1","media1","desktop1","flipper1","club1","flying1","smooth1","monster1","purple1","guardian1","bold1","hyperlink1","presentation1","world1","national1","comment1","element1","magic1","lion1","sand1","crust1","toast1","jam1","hunter1","forest1","foraging1","silently1","tawesomated1","joshing1","pong1","RANDOM1","WORD1"};
char answer[255] = "";
int word;
int vec[20] = { 0 };
int i, j;
int x=0;
srand(time(NULL));
do{
for (i = 0; i < 20; i++) {
int okay = 0;
while (!okay) {
vec[i] = rand() % 100 + 1;
okay = 1;
for (j = 0; j < i; j++) {
if (vec[i] == vec[j]) okay = 0;
}
}
word=vec[i];
printf("%s\n",questions[word]); //print a word
scanf("%255s",answer);// wait for the user to type the word
printf("%s\n",answer[x]);// show what the user typed
printf("%s\n\n",words[word]);// show how they should of typed it
}
}while (x<20,x++);
return 0;
}