How to insert the difference i.e. ineger in a string ?
How to insert the difference i.e. ineger in a string?
Hi @namandubey20
Suppose you have a string s and a interger x which you want to insert in string at position 2. So you have to do following :
s[2]=x+β0β;
This is how at 2nd position your integer x will be placed in the string.
But der sir in this case my s[2] element will be replaced by x, which I donβt want.
Okay in that case your have to use substr as following :
char p=x+β0β;
s=s.substr(0,i)+p+s.substr(i,s.size()+1);
where x is the int value which you want to insert and s is the string and i is the index at which you want to insert the integer.
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.