program to find the length of a string without using strlen() function in c++
Answers
Answered by
0
Answer:
void charcount( char *str)
{
int n=0;
for(int i=0; str[i]!='\n'; i++)
n++;
cout<<n;
}
IF ANY DOUBT THEN RUN IT
Answered by
11
Answer:
Required Program :
To calculate length of a string without using strlen().
# include <iostream>
#include <cstudio>
using namespace std;
int main ( )
{
char s[100], i ;
cout <<"Enter a string : " ;
gets (s) ;
for ( i = 10 ; s[i]! = '\0';++i ) ;
cout << "Length of String : " <<i ;
return 0;;
}
Input :
Enter a string : Programming
Output :
Length of String : 11
Similar questions
Chemistry,
4 months ago
Social Sciences,
4 months ago
Math,
4 months ago
Computer Science,
8 months ago
Chemistry,
8 months ago
History,
11 months ago
Math,
11 months ago