size_t strlen ( const char * str );
char mystr[100]="test string"; 1
2
3
4
5
6
7
8
9
10
11
12
/* strlen example */
#include <stdio.h>
#include <string.h>
int main ()
{
char szInput[256];
printf ("Enter a sentence: ");
gets (szInput);
printf ("The sentence entered is %u characters long.\n",(unsigned)strlen(szInput));
return 0;
}
Enter sentence: just testing The sentence entered is 12 characters long.