diff --git a/std/stdio.c b/std/stdio.c index d1bc69a..1a4d98c 100644 --- a/std/stdio.c +++ b/std/stdio.c @@ -8,5 +8,5 @@ char* readln() { } void print(char *str) { - puts(str); + fputs(str, stdout); } diff --git a/std/stdlib.c b/std/stdlib.c index d27b36f..7e77385 100644 --- a/std/stdlib.c +++ b/std/stdlib.c @@ -1,13 +1,19 @@ #include +#include +#include void wait(long long x) { sleep(x); } -int slen(char *str) { - return strlen(str); +long long slen(char *str) { + return (long long) strlen(str); } -char charAt(char *str, int) { - return str[int]; +char charAt(char *str, long long x) { + return str[x]; +} + +long long parse_int(char *str) { + return (long long) atoi(str); } diff --git a/std/stdlib.sloth b/std/stdlib.sloth index b1849e3..d7ddeff 100644 --- a/std/stdlib.sloth +++ b/std/stdlib.sloth @@ -2,6 +2,7 @@ foreign fn wait(x: Int) Void; foreign fn print(str: String) Void; foreign fn slen(str: String) Int; foreign fn charAt(str: String) Char; +foreign fn parse_int(str: String) Int; fn termpos(x: int, y: int) Void { print("\x1b["); diff --git a/std/stdmath.c b/std/stdmath.c index c9a91c3..dad292f 100644 --- a/std/stdmath.c +++ b/std/stdmath.c @@ -2,10 +2,8 @@ #include #include -int randGen(int min, int max) { - time_t t; - - srand((unsigned) time(&t)); - - return rand() % (max - min + 1) + min; + +long long randGen(long long min, long long max) { + srandom((unsigned) time(NULL)); + return random() % (max - min + 1) + min; }