From 7f32ad51b0f08446d7f66e5403d69299d0d60021 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Fri, 1 Oct 2021 21:10:36 +0200 Subject: c4: added strl* functions cc: started peudo function parsing, currently for void main() only some philosophical thinking and testing around forward function declarations --- miniany/hello.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'miniany/hello.c') diff --git a/miniany/hello.c b/miniany/hello.c index 062ab5f..67cfe1d 100644 --- a/miniany/hello.c +++ b/miniany/hello.c @@ -1,8 +1,38 @@ #include +int f1(int x); + +int f2(int x) +{ + if(x==1) return 0; + f1(x-1); +} + +int f1(int x) +{ + if(x==1) return 0; + f2(x-1); +} + +int f(int x) +{ + if(x==0) return 0; + if(x==1) return 1; + return f(x-1)+f(x-2); +} + int main() { - putstring("hello, world"); + char *s; + s = (char *)malloc(50); + (void)strlcpy(s,"hello, ",50); + (void)strlcat(s,"world",50); + putstring(s); + putnl(); + free(s); + putint(f(10)); + putnl(); + putint(f1(10)); putnl(); return 0; } -- cgit v1.2.3-54-g00ecf