Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>You don't have to use zero-termination

You can choose between zero-termination and having to convert strings back and forth when using idiomatic libraries.



Idiomatic is the wrong word here, because it's certainly not idiomatic to do extra allocations when unneeded. Most APIs let you give the length explicitly if it makes any sense. A not very well-known fact is that even printf format strings let you do printf("%.*s\n", 3, "Hello") which only prints "Hel\n". This is in POSIX C, just not sure when it was standardized.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: