Differnce in ascii codes problem

#include
#include
using namespace std;
int main() {
string s;
cin>>s;
int len=s.length();
string s1=s;
int valinsert=1;
for(int i=0;i<len-1;i++)
{
if(s[i]==’\0’)
{
break;
}
signed int k=s[i+1]-s[i];
string m=to_string(k);

	s1.insert(valinsert,m);
	valinsert+=2;

}
cout<<s1;
	return 0;

}
one test case not passed!!

@manmeetkahlon please save your code on ide.codingblocks.com and share the link.

Hi @manmeetkahlon you increase the value of valinsert by 2 each time you insert an ascii difference in the string, but have you considered if the size of the inserted string is more than 1? like -2 or 10 or -10 in that case you start inserting elements to wrong locations.
An alternative approach could be, you use push_back() or += to append to the string,

  1. the current character (s[i])
  2. the string m.
    Loop over the string s from 0 to len - 1 like you are doing right now.

@Ishitagambhir okay got it!! thankyou so much!!

@manmeetkahlon please mark your doubt as resolved if you are satisfied.