Merge remote-tracking branch 'origin/main'

This commit is contained in:
Sophia 2025-05-01 14:30:43 +02:00
parent 4afea8953f
commit 50d0fcdb6d

View File

@ -3,8 +3,8 @@
// Vergleich zweier Strings ohne Beachtung der Groß-/Kleinschreibung
int string_equals_ignore_case(const char *a, const char *b) {
while (*a && *b) {
if (tolower((unsigned char)*a) != tolower((unsigned char)*b)) {
while (*a && *b) { //läuft so lange bis sie nicht das Ende erreicht haben
if (tolower((unsigned char)*a) != tolower((unsigned char)*b)) { // jedes Zeichen wird in Kleinbuchstaben umgewandelt um beide strings besser zu vergleichen
return 0;
}
a++;
@ -49,12 +49,12 @@ int main() {
char user_colors[2][20]; // Platz für 2 Farben
int attempts = 0;
while (attempts < 2) {
while (attempts < 2) { // läuft so lange bis man zwei gültige Farben eingegeben hat
printf("Bitte gib eine Grundfarbe (Rot, Gruen oder Violett) ein: ");
scanf("%19s", user_colors[attempts]);
while (getchar() != '\n'); // Eingabepuffer leeren
if (is_valid_color(user_colors[attempts])) {
if (is_valid_color(user_colors[attempts])) { // überprüft ob die eingegeben Farbe gültig ist
printf("Du hast %s gewaehlt.\n", user_colors[attempts]);
attempts++;
} else {
@ -62,6 +62,7 @@ int main() {
}
}
// Berechnen der Mischfarbe und Ausgabe der Farbe
printf("Die Mischfarbe ist dann: %s\n", mix_colors(user_colors[0], user_colors[1]));
return 0;