What is wrong with my code?
@goyalvivek in line 15 you are accessing this index, s.length() + 1
. It does not exist. It will not throw an error but it will not do anything either, meaning it will not increase the length of the string. Remember, character arrays and strings might look similar but they are two different datatypes and often behave very differently.
If you want to append something to a string you can use
-
s += "appended_string"
; //to append a string string::insert()
done, thanks for ur help
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.