Is there some trick to define a constant string literal without a
trailing '\0' character?
In C, if you specify the size of a character array to be one less than the size of the string literal initializer, it won't have a trailing null character. You could do it like so:
static const char c_seqence[ARRAY_LEN("___----__--_-_")-1] = "___----__--_-_";
Of course, to avoid having to indicate the string literal twice in the same line, you might want to define a macro to do it:
#define MAKE_STR_LITERAL(n, l) static const char n[ARRAY_LEN(l)-1] = l
You can use it like this:
MAKE_STR_LITERAL(c_seqence, "___----__--_-_");
Note:
As stated in https://stackoverflow.com/a/4348188/2793118, this behavior is in section 6.7.8 of the standard (quoting from that answer):
§ 6.7.8p14
An array of character type may be initialized by a character string
literal, optionally enclosed in braces. Successive characters of the
character string literal (including the terminating null character if
there is room or if the array is of unknown size) initialize the
elements of the array.
Note2: Turns out this is a C-only thing. In C++ it will not compile. Yet another great example of why people shouldn't tag questions with both C and C++.