diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2021-10-01 21:10:36 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2021-10-01 21:10:36 +0200 |
commit | 7f32ad51b0f08446d7f66e5403d69299d0d60021 (patch) | |
tree | 647f786b8f31bdc46b296f9b4b9d40c0375b583d /miniany/hello.c | |
parent | b0c6943121f186c79d2152694d209f82904ff1e1 (diff) | |
download | compilertests-7f32ad51b0f08446d7f66e5403d69299d0d60021.tar.gz compilertests-7f32ad51b0f08446d7f66e5403d69299d0d60021.tar.bz2 |
c4: added strl* functions
cc: started peudo function parsing, currently for void main() only
some philosophical thinking and testing around forward function declarations
Diffstat (limited to 'miniany/hello.c')
-rw-r--r-- | miniany/hello.c | 32 |
1 files changed, 31 insertions, 1 deletions
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 <stdio.h> +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; } |