C Language program to find length of a string


Following program shows you how to find length of a string.
In this program we get string from user and prints the length using strlen()

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

int main(void) {
	char c[100];
	int input;

	printf("Please enter the string:");
	gets(c);

	input = strlen(c);

	printf("Length of the given string is: %d", input);
}

Output:

Please enter the string: tom
Length of the given string is: 3