3 ms·
Why not have the null terminator so you can pass to normal printf? You could even do something crazy with packing a null byte with sz on 64-bit systems (since
by cozzyd 2y ago
Why not have the null terminator so you can pass to normal printf?
You could even do something crazy with packing a null byte with sz on 64-bit systems (since you will never have a string that long anyway...)
- D4ckard 2y agoYes, there are really cool packing techniques. See this talk for example: https://www.youtube.com/watch?v=kPR8h4-qZdk https://www.youtube.com/watch?v=kPR8h4-qZdk I don't include the null-terminator because I use this type in my own environment where I never use null-terminated strings so there is no need for it.
- bigpingo 2y agoprintf("%.*s", len, str); lets you pass the length as an int argument.