diff options
| author | Baitinq <[email protected]> | 2025-06-11 00:16:17 +0200 |
|---|---|---|
| committer | Baitinq <[email protected]> | 2025-06-11 00:16:17 +0200 |
| commit | fa92a157746ae17f295d31b7a047dfeb99624a13 (patch) | |
| tree | 71e469e67a70df15542d873ebe223654def6111b /examples/18.pry | |
| parent | stdlib: Remove println (diff) | |
| download | interpreter-fa92a157746ae17f295d31b7a047dfeb99624a13.tar.gz interpreter-fa92a157746ae17f295d31b7a047dfeb99624a13.tar.bz2 interpreter-fa92a157746ae17f295d31b7a047dfeb99624a13.zip | |
Diffstat (limited to 'examples/18.pry')
| -rw-r--r-- | examples/18.pry | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/18.pry b/examples/18.pry new file mode 100644 index 0000000..32b2d1a --- /dev/null +++ b/examples/18.pry @@ -0,0 +1,30 @@ +extern malloc = (i64) => *void; +extern free = (*void) => void; + +import "!stdlib.pry"; + +let main = () => i64 { + let x = cast(*i8, malloc(24)); + (*(x+cast(*i8, 0))) = 10; + (*(x+cast(*i8, 1))) = 20; + (*(x+cast(*i8, 2))) = 40; + printf("%p\n", x); + printf("%d\n", *(x+cast(*i8, 0))); + printf("%d\n", *(x+cast(*i8, 1))); + printf("%d\n", *(x+cast(*i8, 2))); + free(cast(*void, x)); + return 0; +}; + +/* + +Expected stdout: + +${SOMEPOINTER} +10 +20 +40 + +Expected return: 0 + +*/ |