I know it's possible to use the sizeof function to get the size, but it doesn't get a true count of the array length. If I set an array of int 50 and I stored only 10 numbers in there, I would want to get 10 as the number of elements, but of course that won't happen. I know this is definitely a trivial question, but bear with me here and help me on this if it is possible.
My code so far takes an entire sentence and stores it in an array.
#include <stdio.h>
#include <string.h>
int main()
{
    int i=0;
    char array[50]={0};
    fgets(array, 50, stdin);
    int len = sizeof(array);  // it doesn't work :((((((
    for(i=0; i<len; i++)
    {
        printf("%c\n", array[i]);
    }
    return 0;
}
As you guys can see, if the user decides to only enter a word of lets say "Bobby Foo" then I would want len number of 9 including the space, but the sizeof function only gets length of the size of the array declared which is 50.. >.>..
 
     
     
     
    