Added Method showWordSalad

This commit is contained in:
Tobias Grampp 2025-10-30 16:08:01 +01:00
parent db23fa232e
commit 5be62312c2

View File

@ -2,6 +2,7 @@
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h>
#define MAX_RAND_TRIES_PER_WORD 10 #define MAX_RAND_TRIES_PER_WORD 10
#define EMPTY_CHAR 0 #define EMPTY_CHAR 0
@ -19,5 +20,19 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
// Prints the word salad to console // Prints the word salad to console
void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen) void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)
{ {
if(searchFieldLen <= MAX_SEARCH_FIELD_LEN)
{
for(int i = 0; i < searchFieldLen; i++)
{
for(int j = 0; j < searchFieldLen; j++)
{
putchar(salad[i][j]);//Prints a letter within the salad array
}
putchar(10);//Prints a Line Feed, thus ensuring the correct formatting of the program
}
}
else
{
puts("FEHLER! Buchstabenfeld uebersteigt Maximalzahl der Buchstaben!");
}
} }