Add solution for eingabe.
This commit is contained in:
1 parent
62f5e66043
commit
4500d1752e
2 files changed
+26
No files matched your search
@@ -0,0 +1,20 @@
|
||||
#include "eingabe.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef EINGABE_H
|
||||
#define EINGABE_H
|
||||
|
||||
int gibTextEin(const char *promptText, char *puffer, unsigned int maxLen);
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user