Given two strings(second string with single character) I want to remove all the occurrences of the second string in the first string, I tried executing the below code but it does not stop printing the string after the null character('/0'), instead it takes 0 from the null character and adds it to the string
int j=0;
for(int i=0;i<s.length();i++){
if(s[i]!=c[0]){
s[j]=s[i];
j++;
}
if(i==s.length()-1){
s[j]='/0';
}
I get an output like this :
string 1=hello
string 2=h
output which I get = ello0