The problem is that "and my kingdom too for a blinder"
is a string literal of type const char[33]
and not const char[32]
. The last character is the null character '\0'
. This means that the string literal "and my kingdom too for a blinder"
is equivalent to:
{'a', 'n', 'd', ' ', 'm', 'y', ' ', 'k','i','n','g','d','o','m',' ','t','o','o',' ','f','o', 'r', ' ', 'a', ' ', 'b', 'l', 'i', 'n', 'd', 'e', 'r', '\0'}
Note in the above const char
equivalent array there are 33
characters including the null character '\0'
.
To solve this just change the size of the destination array as shown below:
//---------vv------------------------------------------->changed to 33
char blind[33] = "and my kingdom too for a blinder";