diff --git a/01_strings/eingabe.c b/01_strings/eingabe.c new file mode 100644 index 0000000..3edac63 --- /dev/null +++ b/01_strings/eingabe.c @@ -0,0 +1,20 @@ +#include "eingabe.h" +#include +#include +#include + + +int gibTextEin(const char *promptText, char *puffer, unsigned int maxLen) +{ + if(fgets(puffer, maxLen, stdin) == NULL) + return 0; + else + { + if(puffer[strlen(puffer)-1] == '\n') + puffer[strlen(puffer)-1] = '\0'; + else + while(getchar() != '\n') {} + + return 1; + } +} \ No newline at end of file diff --git a/01_strings/eingabe.h b/01_strings/eingabe.h new file mode 100644 index 0000000..e2ee53f --- /dev/null +++ b/01_strings/eingabe.h @@ -0,0 +1,6 @@ +#ifndef EINGABE_H +#define EINGABE_H + +int gibTextEin(const char *promptText, char *puffer, unsigned int maxLen); + +#endif \ No newline at end of file