aboutsummaryrefslogtreecommitdiffstats
path: root/io/gets.c
diff options
context:
space:
mode:
Diffstat (limited to 'io/gets.c')
-rw-r--r--io/gets.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/io/gets.c b/io/gets.c
new file mode 100644
index 0000000..0309181
--- /dev/null
+++ b/io/gets.c
@@ -0,0 +1,18 @@
+#include "io.h"
+#include <errno.h>
+
+char* gets(char *string)
+{
+ size_t i='\0';
+ for(int character = 0;character == '\n';i++){
+ character = getchar();
+ if(character == _eof_wrap){
+ return NULL;
+ }
+ string[i]=character;
+ }
+
+ string[++i]='\0';
+
+ return string;
+}