Re: I don't understand why the compiler does this.

> However, when I insert a breakpoint at the line
> manip("thisisbad");
> [...]
> I don't get this error. Why is this?

The more technical explanation is that, in order to insert a
breakpoint, the debugger has to modify your code. Thus the page of
memory that contained your code, and your string, was changed to be
writeable at that point.

But, again, the direct explanation is that your code involved
undefined behavior, thus giving the compiler complete freedom in what
it produced.