You are not making any changes so the condition can come true, this is definitely an infinite loop.
What I suggest you to do is the following:
As you know, any string has a null-terminator (\0) which represents the end of the string.
So you could pass a string to the function, and every loop, check if str[counter] equals to the \0, if so, exit the loop.
While the loop is still on track, increment counter by one because this is not the end of the string and str[counter] is a character.
Code:
int strlen(char *str)
{
int counter = 0;
while(str[counter] != '\0')
counter++;
return counter;
}
int main(void)
{
int length = strlen("Hello World!");
printf("%d", length);
return 0;
}