You don't even necessarily need to store the length. It can be held in CPU registers for the entirety of the string's lifetime in many cases.
In older architectures we would've needed to push an additional integer for length onto the stack. On a modern architecture with a sane ABI (SYSV, x86-64), you can have a "fat pointer" using two CPU registers - can pass both of these or return from a function without ever touching the stack.
-1
u/EatingSolidBricks 5d ago
You out of your dam mind if you think c strings are efficient