Literal strings and assignments
When a literal string is assigned to a variable, a copy is made of the string, and the variable is assigned the copy of the literal string. For example, the following code:
for (var i = 0; i < 3; i++)
{
var str = "dog";
Clib.strcat(str, "house");
Clib.puts(str);
}
results in the following output:
doghouse
doghouse
doghouse
A strict C interpretation of this code would not only overwrite memory, but would also generate the following output:
doghouse
doghousehouse
doghousehousehouse
Literal strings and comparisons