mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-31 11:50:07 +00:00
Semicolons are required; when condition for certain file scope declarations; #import syntax change
This commit is contained in:
+2
-30
@@ -1,34 +1,6 @@
|
||||
#import "fmt.odin"
|
||||
#import "utf8.odin"
|
||||
#import "fmt.odin";
|
||||
|
||||
main :: proc() {
|
||||
MAX :: 64
|
||||
buf: [MAX]rune
|
||||
backing: [MAX]byte
|
||||
offset: int
|
||||
|
||||
msg := "Hello"
|
||||
|
||||
count := utf8.rune_count(msg)
|
||||
assert(count <= MAX)
|
||||
runes := buf[:count]
|
||||
|
||||
offset = 0
|
||||
for i := 0; i < count; i++ {
|
||||
s := msg[offset:]
|
||||
r, len := utf8.decode_rune(s)
|
||||
runes[count-i-1] = r
|
||||
offset += len
|
||||
}
|
||||
|
||||
offset = 0
|
||||
for i := 0; i < count; i++ {
|
||||
data, len := utf8.encode_rune(runes[i])
|
||||
copy(backing[offset:], data[:len])
|
||||
offset += len
|
||||
}
|
||||
|
||||
reverse := backing[:offset] as string
|
||||
fmt.println(reverse) // olleH
|
||||
fmt.println("Hellope");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user