Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Did Ken, Ritchie and Brian choose wrong with NUL-terminated text strings? (2011). Parent comment
A couple of ugly corner cases:
const char str[] = "abcd\0efgh"; printf("length = %zu, size = %zu, value = \"%s\"\n", strlen(str), sizeof str, str);
length = 4, size = 10, value = "abcd"
const char str[4] = "abcd"; printf("length = %zu, size = %zu, value = \"%s\"\n", strlen(str), sizeof str, str);
There are no comments on this comment yet.
A couple of ugly corner cases:
output: And: This has undefined behavior. (Which is a good reason to let the compiler figure out how big the array has to be. Computers are better at counting things than you are. Let them.)