aboutsummaryrefslogtreecommitdiffstats
path: root/io/fgets.c
diff options
context:
space:
mode:
author2022-04-07 19:33:30 +0530
committer2022-04-07 19:33:30 +0530
commit54d5ba67489b3fdaf437c05675eb9b1f6d085a84 (patch)
treed53df52fbfb1f440bba34799c2fcf7ff1ce75a57 /io/fgets.c
downloadfflibc-main.tar
fflibc-main.tar.gz
fflibc-main.tar.bz2
fflibc-main.tar.lz
fflibc-main.tar.xz
fflibc-main.tar.zst
fflibc-main.zip
Initial commitmain
Diffstat (limited to 'io/fgets.c')
-rw-r--r--io/fgets.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/io/fgets.c b/io/fgets.c
new file mode 100644
index 0000000..69cd1be
--- /dev/null
+++ b/io/fgets.c
@@ -0,0 +1,15 @@
+#include "io.h"
+#include <errno.h>
+
+char* fgets(char *restrict string, int size, FILE *restrict stream)
+{
+ int character = 0;
+ for(int i=0;character == '\n' || i < size -1;i++){
+ character = _fgetc_wrap(stream);
+ if(character == _eof_wrap){
+ return NULL;
+ }
+ }
+
+ return string;
+}