From 151b2ac99475c89c4f726f3775b1987abe320cfc Mon Sep 17 00:00:00 2001 From: Saba Fazlali Date: Wed, 31 Jan 2024 13:17:31 +0100 Subject: [PATCH] Hangman Initialization --- CMakeLists.txt | 2 ++ cmake-build-debug/.ninja_deps | Bin 10492 -> 10232 bytes cmake-build-debug/.ninja_log | 8 +++----- .../Testing/Temporary/LastTest.log | 4 ++-- cmake-build-debug/build.ninja | 9 ++++++++- src/main/c/Hangman/initializeHangman.c | 16 ++++++++++++++++ src/main/c/Hangman/initializeHangman.h | 8 ++++++++ 7 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 src/main/c/Hangman/initializeHangman.c create mode 100644 src/main/c/Hangman/initializeHangman.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cae33b..a6af89f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,4 +17,6 @@ add_executable(pmuw_projekt_notebinder src/main/c/Hangman/drawHangman.h src/main/c/Hangman/rules.c src/main/c/Hangman/rules.h + src/main/c/Hangman/initializeHangman.c + src/main/c/Hangman/initializeHangman.h ) diff --git a/cmake-build-debug/.ninja_deps b/cmake-build-debug/.ninja_deps index cb10c6589443374fa7cade54fbbf5488f591e6c2..884aefbf537551877b2baf6c41e2bbd0018e5860 100644 GIT binary patch delta 54 zcmewp_``q04%Nwf)ZQ>InEY2gh$(qKkP4QZ_y7O@B@7G=@eB+M6Bk$r#XVjpo&aPg JPF^TG835JE7nlG5 delta 124 zcmez2|0i(64%Nv9@}3$gMTzAeiFxU{iFtY%3=9kY|Np;)fuSLmfq~&{{bjkO57&vu z0on1B7s^hayhHU3>wKV!fXRmP9y~>*IjO~Z$@5?W3J`&exll6_fchpbun>xSyiPn3 J$W8*80RRe;G&cYM diff --git a/cmake-build-debug/.ninja_log b/cmake-build-debug/.ninja_log index 971a097..58af875 100644 --- a/cmake-build-debug/.ninja_log +++ b/cmake-build-debug/.ninja_log @@ -1,11 +1,9 @@ # ninja log v5 1 38 1706122217155672196 CMakeFiles/pmuw_projekt_notebinder.dir/test/Hangman/word_selector_test.c.o e932f546d59a9d76 -0 40 1706551052328412558 build.ninja f2183aada2fc9ffc +0 40 1706703246979925624 build.ninja f2183aada2fc9ffc 1 38 1706122372717341436 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/main.c.o f1dbf76e6b4bc97d 1 145 1706549408123039155 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/word_selector.c.o fab41de4b8cc0421 -1 145 1706549408123027405 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/drawHangman.c.o de5f7edc6c2379d7 -1 44 1706122039878920765 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Template/game100.c.o 69a5bcd8c57a43b3 -168 257 1706178769348509184 pmuw_projekt_notebinder d4d2c5136dd5469e -0 106 1706551301992114407 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/drawHangman.c.o de5f7edc6c2379d7 0 106 1706551301992128657 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/rules.c.o cdaff7b94c55641c +0 106 1706551301992114407 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/drawHangman.c.o de5f7edc6c2379d7 +1 44 1706122039878920765 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Template/game100.c.o 69a5bcd8c57a43b3 106 195 1706551302079685763 pmuw_projekt_notebinder fbb48fd3bf0b96c1 diff --git a/cmake-build-debug/Testing/Temporary/LastTest.log b/cmake-build-debug/Testing/Temporary/LastTest.log index 370c1c4..678f644 100644 --- a/cmake-build-debug/Testing/Temporary/LastTest.log +++ b/cmake-build-debug/Testing/Temporary/LastTest.log @@ -1,3 +1,3 @@ -Start testing: Jan 29 19:01 CET +Start testing: Jan 31 13:14 CET ---------------------------------------------------------- -End testing: Jan 29 19:01 CET +End testing: Jan 31 13:14 CET diff --git a/cmake-build-debug/build.ninja b/cmake-build-debug/build.ninja index 1c8a21f..042faf8 100644 --- a/cmake-build-debug/build.ninja +++ b/cmake-build-debug/build.ninja @@ -77,6 +77,13 @@ build CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/rules.c.o: C_COM OBJECT_DIR = CMakeFiles/pmuw_projekt_notebinder.dir OBJECT_FILE_DIR = CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman +build CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/initializeHangman.c.o: C_COMPILER__pmuw_projekt_notebinder_unscanned_Debug /Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c/Hangman/initializeHangman.c || cmake_object_order_depends_target_pmuw_projekt_notebinder + DEP_FILE = CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/initializeHangman.c.o.d + FLAGS = -g -std=gnu11 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk -fcolor-diagnostics + INCLUDES = -I/Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c -I/Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c/Hangman -I/Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c/Template + OBJECT_DIR = CMakeFiles/pmuw_projekt_notebinder.dir + OBJECT_FILE_DIR = CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman + # ============================================================================= # Link build statements for EXECUTABLE target pmuw_projekt_notebinder @@ -85,7 +92,7 @@ build CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/rules.c.o: C_COM ############################################# # Link the executable pmuw_projekt_notebinder -build pmuw_projekt_notebinder: C_EXECUTABLE_LINKER__pmuw_projekt_notebinder_Debug CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/word_selector.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/main.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/drawHangman.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/rules.c.o +build pmuw_projekt_notebinder: C_EXECUTABLE_LINKER__pmuw_projekt_notebinder_Debug CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/word_selector.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/main.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/drawHangman.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/rules.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/initializeHangman.c.o FLAGS = -g -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk OBJECT_DIR = CMakeFiles/pmuw_projekt_notebinder.dir POST_BUILD = : diff --git a/src/main/c/Hangman/initializeHangman.c b/src/main/c/Hangman/initializeHangman.c new file mode 100644 index 0000000..08b980d --- /dev/null +++ b/src/main/c/Hangman/initializeHangman.c @@ -0,0 +1,16 @@ +#include +#include +#include + +void initializeHangman(char *wordToGuess, char *currentGuess) { + int wordLength = strlen(wordToGuess); + + for (int i = 0; i < wordLength; ++i) { + if (isalpha(wordToGuess[i])) { + currentGuess[i] = '_'; + } else { + currentGuess[i] = wordToGuess[i]; + } + } + currentGuess[wordLength] = '\0'; +} \ No newline at end of file diff --git a/src/main/c/Hangman/initializeHangman.h b/src/main/c/Hangman/initializeHangman.h new file mode 100644 index 0000000..2ea55ca --- /dev/null +++ b/src/main/c/Hangman/initializeHangman.h @@ -0,0 +1,8 @@ +// +// Created by Saba Fazlali on 31.01.24. +// + +#ifndef PMUW_PROJEKT_NOTEBINDER_INITIALIZEHANGMAN_H +#define PMUW_PROJEKT_NOTEBINDER_INITIALIZEHANGMAN_H + +#endif //PMUW_PROJEKT_NOTEBINDER_INITIALIZEHANGMAN_H