I want to get all the sub string possible, there is the following code for it (with all library included), which n is the length of the string s :
long substrCount(int n, string s) {
string sub;
vector<string> s2;
for(int i = 0; i<n; ++i){
for(int j = 0; j <= n-i; j++){
sub = s.substr(i,j);
if(sub != "")
s2.push_back(sub);
}
}
But when I tried with the main for the string "asasd", I get
> s2
> ={a,as,asa,asas,asasd,a,as,asa,asas,asasd,s,sa,sas,sasd,a,as,asa,asas,asasd,s,sa,sas,sasd,a,as,asd,a,as,asa,asas,asasd,s,sa,sas,sasd,a,as,asd,s,sd,a,as,asa,asas,asasd,s,sa,sas,sasd,a,as,asd,s,sd,d}
I do not understand why, the index i is from 0 to n. I should have the string beginning by 's' just after the first asasd.