Return string length: how to use strlen
#include <stdio.h> #include <string.h> int main () { char str[256]; printf ("Enter a sentence: "); gets (str); printf ( "%s is %u characters long\n", str, strlen( str ) ); return 0; }