Browse Source

word selector added

remotes/origin/Saba
Saba Fazlali 11 months ago
parent
commit
188575e4d2
  1. 37
      src/main/c/Hangman/word_selector.c
  2. 16
      src/main/c/Hangman/word_selector.h
  3. 4
      src/main/c/main.c

37
src/main/c/Hangman/word_selector.c

@ -0,0 +1,37 @@
//
// Created by Saba Fazlali on 22.01.24.
//
#include "word_selector.h"
const char wordsList[NUM_WORDS][MAX_WORD_LENGTH + 1] = {
"skill",
"world",
"difference",
"celebration",
"association",
"customer",
"mood",
"agreement",
"audience",
"professor",
"year",
"dealer",
"patience",
"initiative",
"pollution",
"awareness",
"problem",
"vehicle",
"death",
"cousin"
};
const char* selectRandomWord() {
// pick a random number and assign it to index of wordsList array
srand((unsigned int)time(NULL));
int randomIndex = rand() % NUM_WORDS;
return wordsList[randomIndex];
}

16
src/main/c/Hangman/word_selector.h

@ -0,0 +1,16 @@
//
// Created by Saba Fazlali on 24.01.24.
//
#ifndef PMUW_PROJEKT_NOTEBINDER_WORD_SELECTOR_H
#define PMUW_PROJEKT_NOTEBINDER_WORD_SELECTOR_H
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#define MAX_WORD_LENGTH 20
#define NUM_WORDS 20
#endif //PMUW_PROJEKT_NOTEBINDER_WORD_SELECTOR_H

4
src/main/c/main.c

@ -2,7 +2,7 @@
#include <stdlib.h>
#include <stdbool.h>
#include "Template/game100.h"
//#include "Template/game100.h"
int main(){
bool running = true;
@ -37,7 +37,7 @@ int main(){
//start_game4();
break;
case 100:
start_game100();
//start_game100();
break;
case 6:
system("clear");

Loading…
Cancel
Save