From a7711f8d0acccbce7d5e862112342940f8fe8b38 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Fri, 16 Jan 2026 17:14:08 +0100 Subject: Added scrollable areas --- example.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 15 deletions(-) (limited to 'example.c') diff --git a/example.c b/example.c index 67069c7..83c1b1a 100644 --- a/example.c +++ b/example.c @@ -1,27 +1,77 @@ #include #include +typedef enum { + STATUS_IDLE, + STATUS_RUNNING, + STATUS_STOPPED +} Status; + +typedef struct { + int x; + int y; +} Point; + +typedef struct { + Point top_left; + Point bottom_right; +} Rectangle; + typedef struct { - int q; - int w; + int q; + int w; } Bar; -int main(void) { - const char *myenv = getenv("MYENV"); +int add_numbers(int a, int b) { + int result = a + b; + return result; +} + +int fibonacci(int n) { + if (n <= 1) return n; + return fibonacci(n - 1) + fibonacci(n - 2); +} + +void print_rectangle(Rectangle rect) { + printf("> Rect: (%d, %d) to (%d, %d)\n", + rect.top_left.x, rect.top_left.y, + rect.bottom_right.x, rect.bottom_right.y); +} + +int main(int argc, char **argv) { + const char *myenv = getenv("MYENV"); + + int a = 100; + int b = 123; + int c = add_numbers(a, b); + + Bar bar = { .q = 565, .w = 949 }; + Status status = STATUS_RUNNING; + + Rectangle rect = { + .top_left = { .x = 10, .y = 20 }, + .bottom_right = { .x = 50, .y = 80 } + }; + + printf("> MYENV: %s\n", myenv ? myenv : "NULL"); + printf("> c: %d (via add_numbers)\n", c); + printf("> bar.q: %d\n", bar.q); + printf("> status: %d\n", status); - int a = 100; - int b = 123; - int c = a + b; + print_rectangle(rect); - Bar bar = { .q = 565, .w = 949 }; + int fib5 = fibonacci(5); + printf("> fib(5): %d\n", fib5); - printf("> MYENV: %s\n", myenv); - printf("> c: %d\n", c); - printf("> bar.q: %d\n", bar.q); + int arr[] = {10, 20, 30, 40, 50}; + int *ptr = arr; + for (int i = 0; i < 5; i++) { + printf("> arr[%d] = %d (via ptr: %d)\n", i, arr[i], *(ptr + i)); + } - for (int i=0; i<3; i++) { - printf("> loop %d\n", i); - } + for (int i = 0; i < 3; i++) { + printf("> loop %d\n", i); + } - return 0; + return 0; } -- cgit v1.2.3