#include<iostream>
#include<string>
using namespace std;
int main(){
string s1,s2,s3;
int count=0,range1,range2;
cout<<"Manually find substring of two strings "<<endl;
cout<<"string s1 = ";
getline(cin,s1);
cout<<"string s2 = ";
getline(cin,s2);
cout<<"enter the string for which you want substring "<<endl;
cin>>s3;
if(s3=="s1"){
s3=s1;
}
else{
s3=s2;
}
cout<<"enter the range till which you want substring "<<endl;
cout<<"first value = ";
cin>>range1;
cout<<endl;
cout<<" length till which you want substring = ";
cin>>range2;
cout<<endl;
string s4;
s4.resize(range2+1);
for(int x=range1;x<(range1+range2+1);x++){
s4[count++]=s3[x];
}
cout<<"the substring s4 = "<<s4<<endl;
}
EmoticonEmoticon