I cant find an expression to evaluate a part of a string.
I want to get something like that:
if (string[4:8]=='abc') {...}
I started writing like this:
if (string[4]=='a' && string[5]=='b' && string[6]=='c') {...}
but if i need to evaluate a big part of string like
if (string[10:40] == another_string) {...}
then it gets to write TOO much expressions. Are there any ready-to-use solutions?
You could always use
strncmp(), sostring[4:8] == "abc"(which isn’t C syntax, of course) could becomestrncmp(string + 4, "abc", 5) == 0.