From 932fd3ad86da58e6505e0d0ebe01c88498746561 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:09:52 +0100 Subject: [PATCH] =?UTF-8?q?Commit=2011=20-=20func=20nameausgeben=20f=C3=BC?= =?UTF-8?q?r=20func=20startauswahl=20einbauen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 8b0753c..c59d9b1 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -10,6 +10,7 @@ void willkommen(); int namePruefen(); void nameWaehlen(); void startauswahl(); +void nameAusgeben(); void protokoll(){ clear_screen(); @@ -97,4 +98,35 @@ void startauswahl() { } else { printf("Eingabe ungueltig"); } +} + +void nameAusgeben(){ + char KonfDatei[100]; + char name[50]; + int i = 5; + int zaehler = 0; + int nullt; + + FILE *fp = NULL; + fp = fopen("hangman.txt", "r"); + + fscanf(fp, "%s", KonfDatei); + while(KonfDatei[i] != ','){ + zaehler++; + i++; + } + nullt = zaehler; + while(zaehler != 0){ + name[--zaehler] = KonfDatei[--i]; + } + + i = 0; + while(name[i] != 0){ + i++; + } + + name[nullt] = '\0'; + printf("%s\n", name); + + fclose(fp); } \ No newline at end of file