Despite how much I enjoy discovering Zig, I do have trouble wrapping my head around certain concepts, strings literals being one of them.
I just spend some serious time trying to pass a string literal as a function argument. Despite this great article (zig.news/kristoff/what-s-a-string-...), which almost gives the answer, I kept banging my head to the wall.
I finally clicked after reading the post above, so I figure I could as well write it down, maybe it will help others :
pubfnmain()void{functionWithStringLitteral("String litteral as argument");}fnfunctionWithStringLitteral(text:[]constu8)void{std.debug.print("{s}",.{text});}
In other word, you want to pass a slice of immutable u8 values
For further actions, you may consider blocking this person and/or reporting abuse
Despite how much I enjoy discovering Zig, I do have trouble wrapping my head around certain concepts, strings literals being one of them.
I just spend some serious time trying to pass a string literal as a function argument. Despite this great article (zig.news/kristoff/what-s-a-string-...), which almost gives the answer, I kept banging my head to the wall.
I finally clicked after reading the post above, so I figure I could as well write it down, maybe it will help others :
In other word, you want to pass a
slice of immutable u8 values