The code is here
I am unable to understand why s1 and s2 are blank, whereas s3 and s4 store the result.
The code is here
I am unable to understand why s1 and s2 are blank, whereas s3 and s4 store the result.
@devpratik,
In s1: you are storing a null string + first char of string s.
In s2: you are storing a null string + char ‘a’.
In s3: you are initializing a null string. And then adding first char of s.
In s4: you are initializing a null string. And then adding char ‘a’.
The primary difference is initializing a null string. And then adding the char to it.Because in s1, the chars have an ascii value of 1 and 32 (space) and it is taking the String termination character
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.