I'm just curious about what is going on when trying to add a char to a string.
Initially, I thought it would work like a concatenation but it didn't:
cout<<"ab"+'a'<<endl;
cout<<""+'a'<<endl;
Prints

However,
cout<<"bla"<<endl;
cout<<"ab"+'a'<<endl;
cout<<""+'a'<<endl;
Prints

String literals are char const[N] (decays to char const *), and char is a small range integer type. You're doing pointer arithmetic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With