Now lets see this small program
char s[20]="One";
strcat(s,"Two");
cout<<s<<endl;
Here at first s has the value "One" and for visual representation this is the value of s:
O - n - e - \0
Then I add "Two" to the end of the string producing this:
O - n - e - T - w - o - \0
Now as you can see the only null in the string at first was after "One" now it is after "OneTwo"
My question is: Is the null overwritten by the string "Two" and then it adds it's own null at the end.
Or is the null that was already there in the beginning moved back to be at the end again?
(This question might seem not to make a difference but I like to know about everything I learn)
Thank you
strcat
. Usestd::string
and+=
. – Embarrassment