added ws202425 courses
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// typfehler.c
|
||||
//
|
||||
// Benutzereingaben mit Typfehler abfangen
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main() {
|
||||
|
||||
float zahl;
|
||||
int status;
|
||||
char c;
|
||||
|
||||
|
||||
while (1) {
|
||||
printf("Geben Sie eine Zahl ein: ");
|
||||
status = scanf("%f", &zahl);
|
||||
if (status != 0){
|
||||
break;
|
||||
}
|
||||
do {
|
||||
//
|
||||
c = getchar();
|
||||
}
|
||||
while (c != '\n');
|
||||
printf(" Typfehler bei Benutzeingabe");
|
||||
}
|
||||
|
||||
printf("Die Zahl ist %f\n", zahl);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user