4 ms·
I am not writing in C, but always wondered, why pascal-like strings wrappers are not popular, i. e. when you have first 2 bytes represent the length of the stri
by hkpack 1y ago
I am not writing in C, but always wondered, why pascal-like strings wrappers are not popular, i. e. when you have first 2 bytes represent the length of the string following by \0 terminated string for compatibility.
- sirwhinesalot 1y ago2 bytes is not enough, usually you'll see whole "size_t" worth of bytes for the length. But you could do something utf-8 inspired I suppose where some bit pattern in the first byte of the length tells you how many bytes are actually used for the length.
- renewedrebecca 1y agoPascal originally required you to specify the length of the string before you did anything with it. This is a totally good idea, but was considered to be too much of a pain to use at the time.
- hnfong 1y agoIn C you have to do that too, like... malloc()?