#include<iostream>
#include<string>
int strlength(&a);
using namespace std;
int main()
{
string s1,s2;
cout<<"Enter the strings u want to check length::";
cin>>s1>>s2;
strlength(s1);
strlength(s2);
return 0;
}
int strlength(&a)
{
for(int i=0;str[i]!='\0';i++)
{
int count++;
}
cout<<"The length of string is::"<<count;
}
pinaka
0
Newbie Poster
Recommended Answers
Jump to PostSo what is your problem? From what I can see you dont define count in your strlength function. As far as I can remeber strings from the string type are not terminated with a
'\0'
. You can you thesize()
function to find the legnth of the string. You would …
All 4 Replies
NathanOliver
429
Veteran Poster
Featured Poster
Schol-R-LEA
1,446
Commie Mutant Traitor
Featured Poster
Lucaci Andrew
140
Za s|n
pinaka
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.