Merge remote-tracking branch 'origin/main'
This commit is contained in:
parent
4afea8953f
commit
50d0fcdb6d
9
farben.c
9
farben.c
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
// Vergleich zweier Strings ohne Beachtung der Groß-/Kleinschreibung
|
// Vergleich zweier Strings ohne Beachtung der Groß-/Kleinschreibung
|
||||||
int string_equals_ignore_case(const char *a, const char *b) {
|
int string_equals_ignore_case(const char *a, const char *b) {
|
||||||
while (*a && *b) {
|
while (*a && *b) { //läuft so lange bis sie nicht das Ende erreicht haben
|
||||||
if (tolower((unsigned char)*a) != tolower((unsigned char)*b)) {
|
if (tolower((unsigned char)*a) != tolower((unsigned char)*b)) { // jedes Zeichen wird in Kleinbuchstaben umgewandelt um beide strings besser zu vergleichen
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
a++;
|
a++;
|
||||||
@ -49,12 +49,12 @@ int main() {
|
|||||||
char user_colors[2][20]; // Platz für 2 Farben
|
char user_colors[2][20]; // Platz für 2 Farben
|
||||||
int attempts = 0;
|
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: ");
|
printf("Bitte gib eine Grundfarbe (Rot, Gruen oder Violett) ein: ");
|
||||||
scanf("%19s", user_colors[attempts]);
|
scanf("%19s", user_colors[attempts]);
|
||||||
while (getchar() != '\n'); // Eingabepuffer leeren
|
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]);
|
printf("Du hast %s gewaehlt.\n", user_colors[attempts]);
|
||||||
attempts++;
|
attempts++;
|
||||||
} else {
|
} 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]));
|
printf("Die Mischfarbe ist dann: %s\n", mix_colors(user_colors[0], user_colors[1]));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user