From 7d14243f769ad911d7c057b891ed89a95d7c1bfd Mon Sep 17 00:00:00 2001 From: Nic Gaffney Date: Wed, 28 Jun 2023 15:21:54 -0500 Subject: added istr to std --- std/stdlib.c | 11 +++++++---- std/stdlib.sloth | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'std') diff --git a/std/stdlib.c b/std/stdlib.c index dcb7ec3..3878817 100644 --- a/std/stdlib.c +++ b/std/stdlib.c @@ -2,6 +2,7 @@ #include #include #include +#include int wait(int msec) { struct timespec ts; @@ -39,7 +40,9 @@ int as_int(float x) { return (int) x; } -// char* istr(int x) { -// char snum[100]; -// return (char* )itoa(x, snum, 10); -// } +char* istr(int x) { + char* snum[100]; + sprintf(snum, "%d", x); + //char* result = snum; + return snum; +} diff --git a/std/stdlib.sloth b/std/stdlib.sloth index ea57e45..4213e0a 100644 --- a/std/stdlib.sloth +++ b/std/stdlib.sloth @@ -5,6 +5,6 @@ foreign fn slen(str: String) Int; foreign fn parse_int(str: String) Int; foreign fn termpos(x: Int, y: Int); foreign fn as_int(x: Float) Int; -#foreign fn istr(x: Int) Int; +foreign fn istr(x: Int) String; foreign fn termclear() Void; -- cgit v1.2.3