sizeof() returns the size of the operand, not a string length - they are two different things. When you declared 'string[]' it's size was fixed at 8 no matter what you copy into it later. In fact, you are overwriting the bounds of 'string' by copying another string that required 10 bytes. That's a good way to guarantee a program execution error.