I have two different char *
, char *string1
which is constant and char *string2
which can change. I retrieve char *string2
from a list.
I want to find the length of the shortest char *
to use it in:
strncmp(string1, string2, shortest);
.
This will be in a while-loop like below:
...
int shortest;
while (string2) {
// get the length of the shortest char *
if (!strncmp(string1, string2, shortest))
break;
string2 = list_next(list); // Returns NULL if there is no elements left
}
...
I can't use strlen(const char *s)
because it's too slow for my usecase.