I know how to work with a pointer to the beginning of a string, but I don't know how to determine the end.
A pointer to the last character you'd like to print is a possible solution:
void vypis(const char *retezec, const char *end)
{
while (retezec <= end && *retezec != '')
{
putchar(*retezec);
retezec++;
}
putchar('
');
}
int main (void)
{
char *str = NULL;
size_t capacity = 0;
getline(&str, &capacity, stdin);
vypis(str, str + 5); //prints from str[0] to str[5]
vypis(str + 1, str + 3); //prints from str[1] to str[3]
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…