I have a string const char[15] and I want to print it like this:
const char[15]
Label-one: characters [0,13) Label-two: characters [
printf("Label-one: %.*s", 13, str); printf("Label-two: %.*s", 2, str + 13);
@Bob's answer is also acceptable if these lengths are constant, but in case the lengths are determined at runtime, this is the best approach since it parametrises them.