C program to find length of a string using strlen() string function.












C program to find length of a string using strlen() string function.




C program to find length of a string using strlen() string function.



#include <stdio.h> #include <string.h> #define MAX 200 int main() { char text[MAX]; int strlength; printf("\n Enter any string: "); gets(text); strlength = strlen(text); printf("Length of enter string '%s' = %d", text, strlength); return 0; }


Output:
Enter any string: string length Length of enter string 'string length' = 13




Exercise: 1
Write a C program to find length of a string.