diff options
Diffstat (limited to 'examples')
| -rwxr-xr-x | examples/ex1.c | 2 | ||||
| -rw-r--r-- | examples/ex2.c | 11 | ||||
| -rw-r--r-- | examples/ex3.c | 7 | ||||
| -rwxr-xr-x | examples/ex4.c | 7 | ||||
| -rw-r--r-- | examples/ex5.c | 2 |
5 files changed, 16 insertions, 13 deletions
diff --git a/examples/ex1.c b/examples/ex1.c index 2dcff7d..28139f9 100755 --- a/examples/ex1.c +++ b/examples/ex1.c @@ -1,7 +1,7 @@ #! /usr/local/bin/tcc -run #include <tcclib.h> -int main() +int main() { printf("Hello World\n"); return 0; diff --git a/examples/ex2.c b/examples/ex2.c index 6368bee..d415e39 100644 --- a/examples/ex2.c +++ b/examples/ex2.c @@ -1,4 +1,5 @@ -#include "tcclib.h" +#include <stdlib.h> +#include <stdio.h> #define N 20 @@ -23,7 +24,7 @@ int find(int n, int i1, int a, int b, int op) return 1; tab[i1] = n; } - + for(i=0;i<nb_num;i++) { for(j=i+1;j<nb_num;j++) { a = tab[i]; @@ -52,7 +53,7 @@ int find(int n, int i1, int a, int b, int op) if (find(c, i, b, a, '/')) return 1; } - + stack_ptr--; tab[i] = a; tab[j] = b; @@ -66,7 +67,7 @@ int find(int n, int i1, int a, int b, int op) int main(int argc, char **argv) { int i, res, p; - + if (argc < 3) { printf("usage: %s: result numbers...\n" "Try to find result from numbers with the 4 basic operations.\n", argv[0]); @@ -85,7 +86,7 @@ int main(int argc, char **argv) res = find(0, 0, 0, 0, ' '); if (res) { for(i=0;i<=stack_ptr;i++) { - printf("%d %c %d = %d\n", + printf("%d %c %d = %d\n", stack_res[3*i], stack_op[i], stack_res[3*i+1], stack_res[3*i+2]); } diff --git a/examples/ex3.c b/examples/ex3.c index 6f6f630..7c466ad 100644 --- a/examples/ex3.c +++ b/examples/ex3.c @@ -1,4 +1,5 @@ -#include <tcclib.h> +#include <stdlib.h> +#include <stdio.h> int fib(n) { @@ -8,7 +9,7 @@ int fib(n) return fib(n-1) + fib(n-2); } -int main(int argc, char **argv) +int main(int argc, char **argv) { int n; if (argc < 2) { @@ -16,7 +17,7 @@ int main(int argc, char **argv) "Compute nth Fibonacci number\n"); return 1; } - + n = atoi(argv[1]); printf("fib(%d) = %d\n", n, fib(n, 2)); return 0; diff --git a/examples/ex4.c b/examples/ex4.c index 3a3fed7..b33b033 100755 --- a/examples/ex4.c +++ b/examples/ex4.c @@ -1,9 +1,10 @@ #!./tcc -run -L/usr/X11R6/lib -lX11 #include <stdlib.h> -/* Yes, TCC can use X11 too ! */ #include <stdio.h> #include <X11/Xlib.h> +/* Yes, TCC can use X11 too ! */ + int main(int argc, char **argv) { Display *display; @@ -16,8 +17,8 @@ int main(int argc, char **argv) } printf("X11 display opened.\n"); screen = XScreenOfDisplay(display, 0); - printf("width = %d\nheight = %d\ndepth = %d\n", - screen->width, + printf("width = %d\nheight = %d\ndepth = %d\n", + screen->width, screen->height, screen->root_depth); XCloseDisplay(display); diff --git a/examples/ex5.c b/examples/ex5.c index da625c5..156425e 100644 --- a/examples/ex5.c +++ b/examples/ex5.c @@ -1,7 +1,7 @@ #include <stdlib.h> #include <stdio.h> -int main() +int main() { printf("Hello World\n"); return 0; |
