C does not maintain this kind of information. It is up to the developer to implement some way of knowing that the item in the array is valid or not. Typically this is done by selecting an 'invalid value', which is a value that is never going to occur in real data. Another way of doing this is to separately maintain a count.
This is all fine for learning C. If you are doing this for the real world, you would be much better off using data structures like lists. If you are using C++, I would suggest that you learn STL.
Simple C solution would be something like this. The value of "empty" is used to indicate any value which will not occur normally in the input. You can change the #define to any other value you want like "-----" or ".". We begin by initializing the entire array to "empty"
#include <stdio.h>
#include <string.h>
#define MAX_ITEMS 32
#define MAX_LENGTH 32
#define EMPTY "empty"
int main(void)
{
char name[MAX_ITEMS][MAX_LENGTH];
char input[MAX_LENGTH];
int i;
for(i = 0; i < MAX_ITEMS; i++)
{
strcpy(name[i], EMPTY);
}
for(i = 0; i < 10; i++)
{
fgets(input, MAX_LENGTH, stdin);
sscanf(input, "%s", name[i]);
}
for(i = 0; strcmp(name[i], EMPTY) && i < MAX_ITEMS; i++)
{
printf("%s\n", name[i]);
}
return(0);
}