string a = "deepak";
int idx = 2;
char ch = a[idx];
string c = "";
c += a[idx];
cout << c << " ";
cout << endl;
string b = "";
b += a[idx] + a[idx + 1];
cout << b << " ";
Why is c getting printed and not b?
Hello @deepak_four if you want to do that you can do that like this:
actually the way you were doing it is adding their ascii value so the ascii value of 101+112 and thats it is printing unknown character.
Happy Learning!!
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.