Header Ads

Learn Together, Stay Connected.

Finding String Length Without Library Function



 #include<bits/stdc++.h

using namespace std;

int Length(string a)
{
int cnt=0,i=0;
while(a[i++]!='\0')
{
cnt++;
}
return cnt;
}

int main()
{

string a;
cin>>a;

cout<<Length(a)<<endl;

return 0;
}

No comments

Theme images by Dizzo. Powered by Blogger.