C Programming Code Examples C > Strings Code Examples Program to Find Length of String with using user defined function Program to Find Length of String with using user defined function With using User-defined Function Write a Program to Find Length of String After accepting the string from the user we are passing the complete array to the function. Now inside the function we are executing a while loop which will calculate the length of the string. #include<stdio.h> // Prototype Declaration int FindLength(char str[]); int main() { char str[88]; int length; printf("\nEnter the String : "); gets(str); length = FindLength(str); printf("\nLength of the String is : %d", length); return(0); } int FindLength(char str[]) { int len = 0; while (str[len] != '\0') len++; return (len); }