Hy everyone,

I would like to understand a function on strings --> strlen
Below is a code that I took from my teacher where the user inputs a string and prints out the length of the string.

Code:
#include <stdio.h>
#include <string.h>


int main()
{
    char str[100];
    int i = 0;
    
    printf("Enter String: ");
    scanf("%s", str);
    
    while (str[i]!='\0')
    {
        i++;
    }
    printf("The String is\n%s\n", str);
    printf("Length of the string: %lu\n", strlen(str));
}
Now i understand that it returns the count in "int" so my question is:
Let's say i declared
Code:
 int count = 0;
at the beginning of the code
and then made
Code:
count = strlen(str);
why wouldn't i have the same result?
Is there a way to do it also?