2 ms·
But you can't use those string literals in any way without relying on convention.
by magicalhippo 4y ago
But you can't use those string literals in any way without relying on convention.
- int_19h 4y agoThat was my point. Although you can, actually - since literals themselves are array-typed, you can sizeof them to get the character count without relying on null termination. It's even possible to get a non-null-terminated literal if the target array type is not large enough to fit null, e.g.: char s[3] = "foo"; // not null-terminated!
- giantrobot 4y ago> character count Byte count.
- int_19h 4y agoIf you want to be pedantic, "an object declared as type char is large enough to store any member of the basic execution character set". It doesn't actually have to be a byte. In practice, in C context, character == char == byte. Other concepts have to use different names to avoid confusion with the language spec.
- junon 4y agoIn C a 'char' is a 'byte', if we're going to be extra pedantic.