Can't understand error in code

having a problem of resetting thee char array sub_s by making the 0th index as ‘\0’, but i think it is not working,
code:

#include <bits/stdc++.h>
using namespace std;
bool isPalindrome(char sub_s[1000])
{
int i=0;
int j= strlen(sub_s)-1;
while(i <j)
{
if(sub_s[i] != sub_s[j])
{
return false;
}
i++;
j–;
}
return true;
}
int main()
{
char s[1000];
cin.getline(s,1000);
char sub_s[1000];
int cnt =0;
int i=0, j=0;
int k=strlen(s) -1;
while(i <=k)
{
while(j <=k)
{
int start =i;
int m=0;
while(start <= j)
{
sub_s[m] = s[start];
start++;
m++;
}
int length = strlen(sub_s);
sub_s[length] = ‘\0’;
if(isPalindrome(sub_s) == true)
{
cnt++;
}
j++;
}
i++;
j=i;
sub_s[0]= ‘\0’;
}
cout << cnt;
return 0;
}

hi @vedantmendiratta_2b986865346635fc
refer this code -->

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.