Add solution for input test.

This commit is contained in:
paulusja 2025-10-16 13:44:03 +02:00
parent 4c5c651c40
commit 10dd5a42da
2 changed files with 20 additions and 0 deletions

19
02_strings/eingabe.c Normal file
View File

@ -0,0 +1,19 @@
#include <stdio.h>
#include <string.h>
#include "eingabe.h"
int gibTextEin(const char *promptText, char *puffer, unsigned int pufferLen)
{
printf(promptText);
if(fgets(puffer, pufferLen, stdin) != NULL)
{
if(puffer[strlen(puffer)-1] == '\n')
puffer[strlen(puffer)-1] = '\0';
else
while(getchar() != '\n') {}
return 1;
}
return 0;
}

1
02_strings/eingabe.h Normal file
View File

@ -0,0 +1 @@
int gibTextEin(const char *promptText, char *puffer, unsigned int pufferLen);