11 ms·
Why this and not? struct str { sz len; char dat[]; };
by volemo 2y ago
Why this and not?
struct str {
sz len;
char dat[];
};
- b3orn 2y agoHaving a pointer in the struct allows you to increase the string's capacity without changing all the references to it.
- WalterBright 2y agoThose are called "length prefixed strings", or more simply "Pascal strings". The difficulty is one has to reallocate and copy to represent a substring.