diff options
| author | Nic Gaffney <gaffney_nic@protonmail.com> | 2023-11-12 03:01:49 -0600 |
|---|---|---|
| committer | Nic Gaffney <gaffney_nic@protonmail.com> | 2023-11-12 03:01:49 -0600 |
| commit | 52f12c6c2c946d8d3c0a7845d48e11ff8b8fb597 (patch) | |
| tree | 198c2317db2f2876e833384139b47e204a4ad6fe /std/stdio.c | |
| parent | 84c77656e1d5f0414050d8a2dae6c86b022bf125 (diff) | |
| download | sloth-52f12c6c2c946d8d3c0a7845d48e11ff8b8fb597.tar.gz | |
fuck it we ball
Diffstat (limited to 'std/stdio.c')
| -rw-r--r-- | std/stdio.c | 60 |
1 files changed, 24 insertions, 36 deletions
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 <stdio.h> #include <stdlib.h> -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; +} |
