From 52f12c6c2c946d8d3c0a7845d48e11ff8b8fb597 Mon Sep 17 00:00:00 2001 From: Nic Gaffney Date: Sun, 12 Nov 2023 03:01:49 -0600 Subject: fuck it we ball --- std/stdio.c | 60 ++++++++++++++++++++++++------------------------------------ 1 file changed, 24 insertions(+), 36 deletions(-) (limited to 'std/stdio.c') diff --git a/std/stdio.c b/std/stdio.c index b5f1dd0..e9cefd0 100644 --- a/std/stdio.c +++ b/std/stdio.c @@ -1,48 +1,36 @@ #include #include -char* readln() { - char* str = malloc(128); - scanf("%127s", str); - return str; +char *readln() { + char *str = malloc(128); + fgets(str, 127, stdin); + return str; } -void print(char *str) { - fputs(str, stdout); -} +void print(char *str) { fputs(str, stdout); } -void termpos(int x, int y) { - printf("\x1b[%d;%dH", x, y); -} +void termpos(int x, int y) { printf("\x1b[%d;%dH", x, y); } -void termclear() { - printf("\x1b[2J\x1b[H"); -} +void termclear() { printf("\x1b[2J\x1b[H"); } -void curshide() { - print("\x1b[?25l"); -} +void curshide() { print("\x1b[?25l"); } -void cursshow() { - print("\x1b[?25h"); -} +void cursshow() { print("\x1b[?25h"); } -char* filer(char* path) { - FILE *fptr = fopen(path, "rb"); - char *contents = 0; - - if(fptr == NULL) { - return "File not found"; - } - fseek(fptr, 0, SEEK_END); - long size = ftell(fptr); - fseek(fptr, 0, SEEK_SET); - - contents = malloc(size); - fread(contents, 1, size, fptr); - fclose(fptr); - - return contents; -} +char *filer(char *path) { + FILE *fptr = fopen(path, "rb"); + char *contents = 0; + if (fptr == NULL) { + return "File not found"; + } + fseek(fptr, 0, SEEK_END); + long size = ftell(fptr); + fseek(fptr, 0, SEEK_SET); + contents = malloc(size); + fread(contents, 1, size, fptr); + fclose(fptr); + + return contents; +} -- cgit v1.2.3