Program in C++ to find the length of string using user define function
#include<iostream> #include<string.h> #include<conio.h> using namespace std; int StrLen(char *str) { int i; for(i=0;str[i]!='\0';i++); return i; } int main() { char str1[100]; cout<<"Enter string :-"; cin.getline(str1,99); cout<<"Length of string ="<<StrLen(str1); getch(); }
Output:-
Related Programs --
0 Comments