+ 1
Why is cout << 5+"Sololearn" output earn?
need help
2 Respuestas
+ 6
Because "Sololearn" is actually just a pointer to a null terminated string. Since you are adding 5 to the string, you are offsetting the pointer by 5 bytes. Hence you get "earn", which is 5 bytes in from the beginning 'S'
+ 1
the string is an array, a pointer to the first value of a null-terminated string
'S','o','l','o','l','e','a','r','n','\0'
0 , 1 ,2, 3 ,4, 5 , 6 , 7 , 8 , 9
the pointer points to 'S', so 0+5=5, now the pointer points to 'e' and the array starts from there