We have a char. We need to replace all ab characters from our char with the letter c.
Example we have :
abracadabra
the output will be :
cracadcra
I tried to use replace() function from C++, but no success.
#include <iostream>
#include <cstring>
using namespace std;
int main()
  {
  string test;
  cin>>test;
  
  for(int i=0;i<(strlen(test)-1);i++)
  {
      if((test[i]=='a')&&(test[i+1]=='b')){
  test.replace( test[i], 'c' );
      test.replace( test[i+1] , ' ' );     
      }
  }
  cout << test << endl;
  return 0;
  }enter code here
 
     
     
    