I think I see the problem. When I comment out the line "string[0] = ' '", the program works. So then, what if the memory inside the scope of a function is not allowed to be written to outside of that function... the "protected memory" feature I read about in OS X.
To test my theory, I tried compiling for an OS without protected memory. Not finding a compiler for Classic, I installed
TurboC 2.01 under dosbox, and compiled my program there. To my surprise it ran correctly.
So my current theory is that quite simply, Darwin is trying to protect me from myself.
That would also explain why I've never read about this kind of thing, and would explain the nature of the error message I get under OS X.
But wait, hold on. If you replace "string" with an integer array and modify everything else in the program appropriately, the integer array is allowed to be changed. Perhaps the memory protection only happens with strings. Either way this is getting complicated....