summaryrefslogtreecommitdiff
path: root/example.c
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2026-01-16 17:14:08 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2026-01-16 17:14:12 +0100
commita7711f8d0acccbce7d5e862112342940f8fe8b38 (patch)
treea57d6aa07e837b7e026de8e43077299a02b629ee /example.c
parent8543782f2c9dd3fc5af667a5265da786b16e5eb3 (diff)
downloadtoy-debugger-a7711f8d0acccbce7d5e862112342940f8fe8b38.tar.gz
Added scrollable areas
Diffstat (limited to 'example.c')
-rw-r--r--example.c80
1 files changed, 65 insertions, 15 deletions
diff --git a/example.c b/example.c
index 67069c7..83c1b1a 100644
--- a/example.c
+++ b/example.c
@@ -1,27 +1,77 @@
#include <stdio.h>
#include <stdlib.h>
+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;
}