by qsort · 2y ago · 0 comments
From a purely linguistic standpoint, the choice is sound. Obviously it's objectively a disaster but for unrelated reasons.
They can, only some functions stop at the first zero:
char s[] = "gogo\x00gogo";
printf( "%d\n", (int)sizeof( s ) );Consider the following program:
#include <stdio.h>
#include <string.h>
int main()
{
const char * const s = "gogo\x00gogo";
const char t[] = "gogo\x00gogo";
printf("%d,%d,%d,%d\n",
(int)sizeof s,
(int)strlen(s), // DO NOT EVER USE THIS FUNCTION
// YOU WILL BE FIRED IF YOU DO
(int)sizeof t,
(int)strlen(t) // DO NOT EVER USE THIS FUNCTION
// YOU WILL BE FIRED IF YOU DO
);
}
> 8,4,10,4> They can, only some functions stop at the first zero:
> char s[] = "gogo\x00gogo";
And in what human language is that `\x00` a valid character? What rune/glyph/symbol represents it?
Nothing, you say? Well, looks like a good choice to me.